From: Toby J. <pu...@to...> - 2002-07-31 16:13:07
|
There is an option to set the PASSWD environment variable within the startup script /etc/init.d/backuppc. However, since passing the "--user" argument to "daemon" (the shell function that starts and logs the service) causes BackupPC to be started via su, the environment is reset, even if PASSWD is exported. There is an option "-m" to su that preserves the caller's environment; however this is probably not desirable since the service is usually started by root at system boot. Setting PASSWD in the startup script (rather than config.pl) is desirable to me since I can leave it readable by root only, while config.pl is group-readable for admins. The workaround I have implemented is to create a second command-line argument to BackupPC, -p, which contains the password: daemon --user <username> /path/to/bin/BackupPC -d -p "'$PASSWD'" (There can't be any quotes in the password this way, but I don't know enough about shell scripting to do it better). Then I read the password from $opts{p} and put it into %ENV. Which brings me to a second issue: the global %opts hash you use. I haven't coded for mod_perl much, but my understanding is that global variables, unless explicitly set, are in danger of being carried over to subsequent calls of the script by the same httpd child process. I don't believe 'getopts' actually clears out the %opts hash, so shouldn't that be done explicitly beforehand with a "my %opts = ()"? Lastly, the environment variable $PASSWD seems a little too generic. Possibly better as $BACKUPPC_PASSWD or even $BACKUPPC_SMB_PASSWD? |