From 24bc165bb0dc6faa16f41efde756491221989c2a Mon Sep 17 00:00:00 2001 From: Alexey Gladkov Date: Fri, 19 Nov 2021 15:57:34 +0300 Subject: Add option to switch off permission check Signed-off-by: Alexey Gladkov --- fetchmail.c | 5 +++-- fetchmail.h | 1 + options.c | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fetchmail.c b/fetchmail.c index 9edcd76a..814643ca 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -75,6 +75,7 @@ flag quitmode; /* if --quit was set */ int quitind; /* optind after position of last --quit option */ flag check_only; /* if --probe was set */ flag versioninfo; /* emit only version info */ +flag permcheck = TRUE; /* perform permission checks on files */ char *user; /* the name of the invoking user */ char *home; /* invoking user's home directory */ char *fmhome; /* fetchmail's home directory */ @@ -407,7 +408,7 @@ int main(int argc, char **argv) { int st; - if (!versioninfo && (st = prc_filecheck(run.idfile, !versioninfo)) != 0) { + if (!versioninfo && (st = prc_filecheck(run.idfile, TRUE)) != 0) { exit(st); } else { if ((st = initialize_saved_lists(querylist, run.idfile))) { @@ -1131,7 +1132,7 @@ static int load_params(int argc, char **argv, int optind) } /* this builds the host list */ - if ((st = prc_parse_file(rcfile, !versioninfo)) != 0) + if ((st = prc_parse_file(rcfile, permcheck)) != 0) /* * FIXME: someday, send notification mail here if backgrounded. * Right now, that can happen if the user changes the rcfile diff --git a/fetchmail.h b/fetchmail.h index a1b77468..a4305e5c 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -457,6 +457,7 @@ extern flag check_only; /* if --check was set */ extern char *rcfile; /* path name of rc file */ extern int linelimit; /* limit # lines retrieved per site */ extern flag versioninfo; /* emit only version info */ +extern flag permcheck; /* perform permission checks on files */ extern char *user; /* name of invoking user */ extern char *home; /* home directory of invoking user */ extern char *fmhome; /* fetchmail home directory */ diff --git a/options.c b/options.c index 90eeaaff..e2fdbbae 100644 --- a/options.c +++ b/options.c @@ -28,6 +28,7 @@ enum { LA_PIDFILE, LA_SYSLOG, LA_NOSYSLOG, + LA_NOPERMCHECK, LA_POSTMASTER, LA_NOBOUNCE, LA_AUTH, @@ -80,6 +81,7 @@ static const struct option longoptions[] = { {"syslog", no_argument, (int *) 0, LA_SYSLOG }, {"nosyslog", no_argument, (int *) 0, LA_NOSYSLOG }, {"fetchmailrc",required_argument,(int *) 0, 'f' }, + {"nopermcheck",no_argument, (int *) 0, LA_NOPERMCHECK }, {"idfile", required_argument, (int *) 0, 'i' }, {"pidfile", required_argument, (int *) 0, LA_PIDFILE }, {"postmaster",required_argument, (int *) 0, LA_POSTMASTER }, @@ -272,6 +274,7 @@ int parsecmdline (int argc /** argument count */, case 'V': versioninfo = TRUE; option_safe = TRUE; + permcheck = FALSE; break; case 'c': check_only = TRUE; @@ -310,6 +313,9 @@ int parsecmdline (int argc /** argument count */, xfree(rcfile); rcfile = prependdir (optarg, currentwd); break; + case LA_NOPERMCHECK: + permcheck = FALSE; + break; case 'i': rctl->idfile = prependdir (optarg, currentwd); break; -- 2.25.4