Add option 't' to set syslog tag

This commit is contained in:
benrubson 2017-04-02 21:06:41 +02:00 committed by rfjakob
parent b1a7e0ff5e
commit c68c130724
2 changed files with 14 additions and 1 deletions

View File

@ -66,6 +66,11 @@ Normally these logging messages are disabled and have no effect. It is
recommended that you run in foreground (B<-f>) mode when running with verbose recommended that you run in foreground (B<-f>) mode when running with verbose
enabled. enabled.
=item B<-t>, B<--syslogtag>
This option allows to set the syslog tag which will be used when messages are
logged via syslog. By default the syslog tag is set to B<encfs>.
=item B<-s> =item B<-s>
The B<-s> (I<single threaded>) option causes B<EncFS> to run in single threaded The B<-s> (I<single threaded>) option causes B<EncFS> to run in single threaded

View File

@ -80,6 +80,7 @@ struct EncFS_Args {
int idleTimeout; // 0 == idle time in minutes to trigger unmount int idleTimeout; // 0 == idle time in minutes to trigger unmount
const char *fuseArgv[MaxFuseArgs]; const char *fuseArgv[MaxFuseArgs];
int fuseArgc; int fuseArgc;
std::string syslogTag; // syslog tag to use when logging using syslog
std::shared_ptr<EncFS_Opts> opts; std::shared_ptr<EncFS_Opts> opts;
@ -190,6 +191,7 @@ static bool processArgs(int argc, char *argv[],
out->isVerbose = false; out->isVerbose = false;
out->idleTimeout = 0; out->idleTimeout = 0;
out->fuseArgc = 0; out->fuseArgc = 0;
out->syslogTag = "encfs";
out->opts->idleTracking = false; out->opts->idleTracking = false;
out->opts->checkKey = true; out->opts->checkKey = true;
out->opts->forceDecode = false; out->opts->forceDecode = false;
@ -225,6 +227,7 @@ static bool processArgs(int argc, char *argv[],
{"extpass", 1, 0, 'p'}, // external password program {"extpass", 1, 0, 'p'}, // external password program
// {"single-thread", 0, 0, 's'}, // single-threaded mode // {"single-thread", 0, 0, 's'}, // single-threaded mode
{"stdinpass", 0, 0, 'S'}, // read password from stdin {"stdinpass", 0, 0, 'S'}, // read password from stdin
{"syslogtag", 1, 0, 't'}, // syslog tag
{"annotate", 0, 0, {"annotate", 0, 0,
LONG_OPT_ANNOTATE}, // Print annotation lines to stderr LONG_OPT_ANNOTATE}, // Print annotation lines to stderr
{"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching {"nocache", 0, 0, LONG_OPT_NOCACHE}, // disable caching
@ -247,8 +250,9 @@ static bool processArgs(int argc, char *argv[],
// 'm' : mount-on-demand // 'm' : mount-on-demand
// 'S' : password from stdin // 'S' : password from stdin
// 'o' : arguments meant for fuse // 'o' : arguments meant for fuse
// 't' : syslog tag
int res = int res =
getopt_long(argc, argv, "HsSfvdmi:o:", long_options, &option_index); getopt_long(argc, argv, "HsSfvdmi:o:t:", long_options, &option_index);
if (res == -1) break; if (res == -1) break;
@ -265,6 +269,9 @@ static bool processArgs(int argc, char *argv[],
case 'S': case 'S':
out->opts->useStdin = true; out->opts->useStdin = true;
break; break;
case 't':
out->syslogTag = optarg;
break;
case LONG_OPT_ANNOTATE: case LONG_OPT_ANNOTATE:
out->opts->annotate = true; out->opts->annotate = true;
break; break;
@ -535,6 +542,7 @@ int main(int argc, char *argv[]) {
} }
encfs::initLogging(encfsArgs->isVerbose, encfsArgs->isDaemon); encfs::initLogging(encfsArgs->isVerbose, encfsArgs->isDaemon);
ELPP_INITIALIZE_SYSLOG(encfsArgs->syslogTag.c_str(), 0, 0);
VLOG(1) << "Root directory: " << encfsArgs->opts->rootDir; VLOG(1) << "Root directory: " << encfsArgs->opts->rootDir;
VLOG(1) << "Fuse arguments: " << encfsArgs->toString(); VLOG(1) << "Fuse arguments: " << encfsArgs->toString();