summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmadeusz Sławiński <amade@asmblr.net>2017-02-07 13:32:24 +0100
committerAmadeusz Sławiński <amade@asmblr.net>2017-02-07 22:50:51 +0100
commit18193bc7b237d66a076fffa21d4308dbb4f83cc5 (patch)
treeb16ff0518f14dc5ad85e76f27e1eac8dac067ede
parent1c6d2817926d30c9a7a97d99af7ac5de4a5845b8 (diff)
downloadscreen-18193bc7b237d66a076fffa21d4308dbb4f83cc5.tar.gz
make -L logfile into separate -Logfile parameter
Also drop file checking, as it became clear that it doesn't make much sense for example with "-Logfile 'logfile.%n'" each window would have it's own logfile and in theory we would need to check them all and still someone could prevent us to open logfile at runtime due to creating conflicting file with properly crafted permissions, before we open a window.
-rw-r--r--src/screen.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/screen.c b/src/screen.c
index b03a66d..9fe3233 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -672,26 +672,20 @@ int main(int ac, char** av)
break;
case 'L':
- if (--ac > 1 && !strcmp(*++av, "logfile")) {
- *++av; // Now '*av' is a logfile parameter
- --ac;
+ if (!strcmp(ap + 1, "ogfile")) {
+ if (--ac == 0)
+ exit_with_usage(myname, "Specify logfile path with -Logfile", NULL);
- if (strlen(*av) > PATH_MAX)
- Panic(1, "-L: logfile name too long. (max. %d char)", PATH_MAX);
- if (*av[0] == '-')
- Panic(0, "-L: logfile name can not start with \"-\" symbol");
+ if (strlen(*++av) > PATH_MAX)
+ Panic(1, "-Logfile name too long. (max. %d char)", PATH_MAX);
+ free(screenlogfile); /* we already set it up while starting */
screenlogfile = SaveStr(*av);
- }
- struct Log *w_check;
- if ((w_check = logfopen(screenlogfile, islogfile(screenlogfile) ? NULL : secfopen(screenlogfile, "a"))) == NULL)
- Panic(0, "-L: logfile name access problem");
- else
- if (logfclose (w_check)) //logfclose does free()
- Panic(0, "-L: logfile is broken...");
+ ap = NULL;
+ } else if (!strcmp(ap, "L"))
+ nwin_options.Lflag = 1;
- nwin_options.Lflag = 1;
break;
case 'm':