Fix line break CRLF to LF

This commit is contained in:
Wanderlei Hüttel 2023-11-06 19:38:13 -03:00
parent e28af92dd0
commit 694d5ab55e
5 changed files with 1065 additions and 1065 deletions

View File

@ -1,78 +1,78 @@
# Example vchanger 1.0.2 config file # Example vchanger 1.0.2 config file
# #
# Storage Resource Name of the Storage resource defined in bacula-dir.conf # Storage Resource Name of the Storage resource defined in bacula-dir.conf
# that is associated with this changer. # that is associated with this changer.
# [Default: 'vchanger' ] # [Default: 'vchanger' ]
#Storage Resource = "vchanger" #Storage Resource = "vchanger"
# #
# User User to run as when invoked by root. This must be the # User User to run as when invoked by root. This must be the
# owner of the volume files controlled by this changer, and # owner of the volume files controlled by this changer, and
# so will need to be the same user that bacula-sd runs as. # so will need to be the same user that bacula-sd runs as.
# [Default: bacula ] # [Default: bacula ]
#User = bacula #User = bacula
# #
# Group Group to run as when invoked by root. This should be the # Group Group to run as when invoked by root. This should be the
# owner group of the volume files controlled by this changer, # owner group of the volume files controlled by this changer,
# and should also be the default group of the user that # and should also be the default group of the user that
# bacula-sd runs as. # bacula-sd runs as.
# [Default: tape ] # [Default: tape ]
#group = tape #group = tape
# #
# Work Dir Directory where virtual drive and magazine state information # Work Dir Directory where virtual drive and magazine state information
# and symlinks for this changer are stored. # and symlinks for this changer are stored.
# [Default: /var/spool/vchanger/{StorageResource} ] # [Default: /var/spool/vchanger/{StorageResource} ]
#work dir = "/var/spool/vchanger/vcahnger" #work dir = "/var/spool/vchanger/vcahnger"
# #
# Logfile Path to log file for this changer. # Logfile Path to log file for this changer.
# [Default: {WorkDir}/{StorageResource}.log ] # [Default: {WorkDir}/{StorageResource}.log ]
#logfile = "/var/spool/vchanger/vchanger.log" #logfile = "/var/spool/vchanger/vchanger.log"
# #
# Log Level Sets the level of detail being logged. An integer value from # Log Level Sets the level of detail being logged. An integer value from
# 0-7 is expected, where 7 logs the most detail. The levels # 0-7 is expected, where 7 logs the most detail. The levels
# correspond to LOG_EMERG - LOG_DEBUG. (See man 3 syslog) # correspond to LOG_EMERG - LOG_DEBUG. (See man 3 syslog)
# [Default: 3 (LOG_ERR) ] # [Default: 3 (LOG_ERR) ]
#log_level = 3 #log_level = 3
# #
# bconsole Sets the path to the bconsole binary that vchanger will run # bconsole Sets the path to the bconsole binary that vchanger will run
# in order to send 'update slots' and 'label barcodes' commands # in order to send 'update slots' and 'label barcodes' commands
# to Bacula. To disable sending commands to Bacula, set # to Bacula. To disable sending commands to Bacula, set
# bconsole="". # bconsole="".
# [Default: "/usr/sbin/bconsole" ] # [Default: "/usr/sbin/bconsole" ]
#bconsole = "/usr/sbin/bconsole" #bconsole = "/usr/sbin/bconsole"
# #
# bconsole config Path to the config file bconsole will use when vchanger # bconsole config Path to the config file bconsole will use when vchanger
# invokes bconsole. By default, bconsole will be invoked # invokes bconsole. By default, bconsole will be invoked
# without the -c flag. The file must be readable by the user # without the -c flag. The file must be readable by the user
# vchanger is run as. # vchanger is run as.
# [Default: none ] # [Default: none ]
#bconsole config = /etc/bacula/bconsole.conf #bconsole config = /etc/bacula/bconsole.conf
# #
# Default Pool Name of the pool that new volumes created by vcahnger # Default Pool Name of the pool that new volumes created by vcahnger
# should be placed into when using bconsole to send a # should be placed into when using bconsole to send a
# 'label barcodes' command. # 'label barcodes' command.
# [Default: "Scratch" ] # [Default: "Scratch" ]
#default pool = "Scratch" #default pool = "Scratch"
# #
# Magazine [Required] Gives the list of magazines known to this changer. # Magazine [Required] Gives the list of magazines known to this changer.
# One or more magazine directives must be specified. A magazine # One or more magazine directives must be specified. A magazine
# may be specified as either a directory path or as the UUID # may be specified as either a directory path or as the UUID
# of a filesystem partition. A magazine is specified by UUID # of a filesystem partition. A magazine is specified by UUID
# by prefixing the string "UUID:" to the filesystem's UUID. # by prefixing the string "UUID:" to the filesystem's UUID.
# For magazines specified by UUID, the mountpoint of the # For magazines specified by UUID, the mountpoint of the
# filesystem will be queried from the system. Note that vchanger # filesystem will be queried from the system. Note that vchanger
# does not attempt to mount the magazines that are specified # does not attempt to mount the magazines that are specified
# by filesystem UUID. Vchanger utilizes all magazines that are # by filesystem UUID. Vchanger utilizes all magazines that are
# already mounted at the time it is invoked. # already mounted at the time it is invoked.
# [Default: none ] # [Default: none ]
#magazine = "uuid:4fcb1422-f15c-4d7a-8a32-a4dcc0af5e00" #magazine = "uuid:4fcb1422-f15c-4d7a-8a32-a4dcc0af5e00"
#Magazine = "/mnt/backup2" #Magazine = "/mnt/backup2"

View File

@ -1,24 +1,24 @@
/* The following macros define the minimum required platform. The minimum required platform /* The following macros define the minimum required platform. The minimum required platform
* is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run * is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
* your application. The macros work by enabling all features available on platform versions up to and * your application. The macros work by enabling all features available on platform versions up to and
* including the version specified. * including the version specified.
* *
* Modify the following defines if you have to target a platform prior to the ones specified below. * Modify the following defines if you have to target a platform prior to the ones specified below.
* Refer to MSDN for the latest info on corresponding values for different platforms. * Refer to MSDN for the latest info on corresponding values for different platforms.
*/ */
#ifndef _TARGETVER_H_ #ifndef _TARGETVER_H_
#define _TARGETVER_H_ 1 #define _TARGETVER_H_ 1
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
#ifndef WINVER #ifndef WINVER
#define WINVER 0x0600 #define WINVER 0x0600
#endif #endif
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600 #define _WIN32_WINNT 0x0600
#endif #endif
#ifndef _WIN32_IE #ifndef _WIN32_IE
#define _WIN32_IE 0x0700 #define _WIN32_IE 0x0700
#endif #endif
#define _POSIX 1 #define _POSIX 1
#endif #endif
#endif #endif

View File

@ -1,192 +1,192 @@
/* util.cpp /* util.cpp
* *
* This file is part of vchanger by Josh Fisher. * This file is part of vchanger by Josh Fisher.
* *
* vchanger copyright (C) 2008-2014 Josh Fisher * vchanger copyright (C) 2008-2014 Josh Fisher
* *
* vchanger is free software. * vchanger is free software.
* You may redistribute it and/or modify it under the terms of the * You may redistribute it and/or modify it under the terms of the
* GNU General Public License version 2, as published by the Free * GNU General Public License version 2, as published by the Free
* Software Foundation. * Software Foundation.
* *
* vchanger is distributed in the hope that it will be useful, * vchanger is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with vchanger. See the file "COPYING". If not, * along with vchanger. See the file "COPYING". If not,
* write to: The Free Software Foundation, Inc., * write to: The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, * 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
* *
* This file simply provides some utility functions * This file simply provides some utility functions
*/ */
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_STDLIB_H #ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
#include <string.h> #include <string.h>
#endif #endif
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>
#endif #endif
#ifdef HAVE_ERRNO_H #ifdef HAVE_ERRNO_H
#include <errno.h> #include <errno.h>
#endif #endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef HAVE_STDARG_H #ifdef HAVE_STDARG_H
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#ifdef HAVE_SYS_STAT_H #ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#ifdef HAVE_FCNTL_H #ifdef HAVE_FCNTL_H
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef HAVE_GRP_H #ifdef HAVE_GRP_H
#include <grp.h> #include <grp.h>
#endif #endif
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
#endif #endif
#ifdef HAVE_TIME_H #ifdef HAVE_TIME_H
#include <time.h> #include <time.h>
#endif #endif
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "util.h" #include "util.h"
/*------------------------------------------------- /*-------------------------------------------------
* Function to return elapsed time between two struct timeval values * Function to return elapsed time between two struct timeval values
* in microseconds. * in microseconds.
*------------------------------------------------*/ *------------------------------------------------*/
long timeval_et(struct timeval *tv1, struct timeval *tv2) long timeval_et(struct timeval *tv1, struct timeval *tv2)
{ {
if (!tv1 || !tv2) return 0; if (!tv1 || !tv2) return 0;
return ((tv2->tv_sec - tv1->tv_sec) * 1000000) + tv2->tv_usec - tv1->tv_usec; return ((tv2->tv_sec - tv1->tv_sec) * 1000000) + tv2->tv_usec - tv1->tv_usec;
} }
/*------------------------------------------------- /*-------------------------------------------------
* Function to open file 'fname' for write in exclusive access mode. * Function to open file 'fname' for write in exclusive access mode.
* On success, returns the opened stream. Otherwise, on error returns * On success, returns the opened stream. Otherwise, on error returns
* NULL. * NULL.
*------------------------------------------------*/ *------------------------------------------------*/
int exclusive_fopen(const char *fname, FILE **fs) int exclusive_fopen(const char *fname, FILE **fs)
{ {
int fd, result = 0; int fd, result = 0;
*fs = NULL; *fs = NULL;
fd = open(fname, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); fd = open(fname, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
if (fd > 0) { if (fd > 0) {
*fs = fdopen(fd, "w"); *fs = fdopen(fd, "w");
if (*fs == NULL) { if (*fs == NULL) {
result = errno; result = errno;
close(fd); close(fd);
unlink(fname); unlink(fname);
} }
} else { } else {
result = errno; result = errno;
} }
return result; return result;
} }
/*------------------------------------------------- /*-------------------------------------------------
* Function to copy file 'from_path' to new file 'to_path'. * Function to copy file 'from_path' to new file 'to_path'.
* On success returns zero, else returns errno * On success returns zero, else returns errno
*------------------------------------------------*/ *------------------------------------------------*/
int file_copy(const char *to_path, const char *from_path) int file_copy(const char *to_path, const char *from_path)
{ {
int rc; int rc;
size_t n; size_t n;
FILE *to, *from; FILE *to, *from;
char *buf; char *buf;
size_t buf_sz = 1024 * 1024; size_t buf_sz = 1024 * 1024;
if (access(to_path, F_OK) == 0) return EEXIST; if (access(to_path, F_OK) == 0) return EEXIST;
from = fopen(from_path, "r"); from = fopen(from_path, "r");
if (!from) return errno; if (!from) return errno;
to = fopen(to_path, "w"); to = fopen(to_path, "w");
if (!to) { if (!to) {
rc = errno; rc = errno;
fclose(from); fclose(from);
return rc; return rc;
} }
buf = (char*)malloc(buf_sz); buf = (char*)malloc(buf_sz);
while ((n = fread(buf, 1, buf_sz, from)) > 0) { while ((n = fread(buf, 1, buf_sz, from)) > 0) {
if (fwrite(buf, 1 , n, to) != n) { if (fwrite(buf, 1 , n, to) != n) {
rc = ferror(to); rc = ferror(to);
fclose(to); fclose(to);
unlink(to_path); unlink(to_path);
fclose(from); fclose(from);
free(buf); free(buf);
return rc; return rc;
} }
} }
free(buf); free(buf);
fclose(to); fclose(to);
if (!feof(from)) { if (!feof(from)) {
rc = ferror(from); rc = ferror(from);
unlink(to_path); unlink(to_path);
fclose(from); fclose(from);
return rc; return rc;
} }
fclose(from); fclose(from);
return 0; return 0;
} }
/*------------------------------------------------- /*-------------------------------------------------
* Function to drop root privileges and change persona to uid:gid * Function to drop root privileges and change persona to uid:gid
* of the given user name and group name. * of the given user name and group name.
* On success returns zero, else on error returns errno. * On success returns zero, else on error returns errno.
*------------------------------------------------*/ *------------------------------------------------*/
int drop_privs(const char *uname, const char *gname) int drop_privs(const char *uname, const char *gname)
{ {
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
return 0; /* For windows ignore user switching */ return 0; /* For windows ignore user switching */
#else #else
gid_t new_gid; gid_t new_gid;
struct passwd *pw; struct passwd *pw;
struct group *gr; struct group *gr;
if (!uname || !uname[0] || getuid()) return 0; /* Nothing to do */ if (!uname || !uname[0] || getuid()) return 0; /* Nothing to do */
if ((pw = getpwnam(uname)) == NULL) return errno; if ((pw = getpwnam(uname)) == NULL) return errno;
if (pw->pw_uid == 0) return 0; /* already running as root */ if (pw->pw_uid == 0) return 0; /* already running as root */
new_gid = pw->pw_gid; new_gid = pw->pw_gid;
if (gname && gname[0]) { if (gname && gname[0]) {
/* find given group */ /* find given group */
if ((gr = getgrnam(gname)) == NULL) return errno; /* no such group */ if ((gr = getgrnam(gname)) == NULL) return errno; /* no such group */
new_gid = gr->gr_gid; new_gid = gr->gr_gid;
} }
/* Set supplemental groups */ /* Set supplemental groups */
if (initgroups(uname, new_gid)) return errno; if (initgroups(uname, new_gid)) return errno;
/* Start running as given group */ /* Start running as given group */
if (setgid(new_gid)) return errno; if (setgid(new_gid)) return errno;
/* Drop root and run as given user */ /* Drop root and run as given user */
if (setuid(pw->pw_uid)) return errno; if (setuid(pw->pw_uid)) return errno;
return 0; return 0;
#endif #endif
} }
/*------------------------------------------------- /*-------------------------------------------------
* Function returns zero if current user not superuser * Function returns zero if current user not superuser
* else non-zero. * else non-zero.
*------------------------------------------------*/ *------------------------------------------------*/
int is_root_user() int is_root_user()
{ {
#ifndef HAVE_WINDOWS_H #ifndef HAVE_WINDOWS_H
return getuid() == 0 ? 1 : 0; return getuid() == 0 ? 1 : 0;
#endif #endif
return 0; return 0;
} }

View File

@ -1,37 +1,37 @@
/* uuidlookup.h /* uuidlookup.h
* *
* This file is part of vchanger by Josh Fisher. * This file is part of vchanger by Josh Fisher.
* *
* vchanger copyright (C) 2008-2013 Josh Fisher * vchanger copyright (C) 2008-2013 Josh Fisher
* *
* vchanger is free software. * vchanger is free software.
* You may redistribute it and/or modify it under the terms of the * You may redistribute it and/or modify it under the terms of the
* GNU General Public License version 2, as published by the Free * GNU General Public License version 2, as published by the Free
* Software Foundation. * Software Foundation.
* *
* vchanger is distributed in the hope that it will be useful, * vchanger is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with vchanger. See the file "COPYING". If not, * along with vchanger. See the file "COPYING". If not,
* write to: The Free Software Foundation, Inc., * write to: The Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, * 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#ifndef __UUIDLOOKUP_H_ #ifndef __UUIDLOOKUP_H_
#define __UUIDLOOKUP_H_ #define __UUIDLOOKUP_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
int GetMountpointFromUUID(char *mountp, size_t mountp_sz, const char *uuid_str); int GetMountpointFromUUID(char *mountp, size_t mountp_sz, const char *uuid_str);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __UUIDLOOKUP_H_ */ #endif /* __UUIDLOOKUP_H_ */

File diff suppressed because it is too large Load Diff