SHA256
1
0
forked from pool/screen
screen/fix_enable_logfile.patch

73 lines
2.5 KiB
Diff

From: Alexander Naumov <alexander_naumov@opensuse.org>
Date: Thu, 26 Jan 2017 23:44:43 +0100
Subject: [PATCH] Adding "-L logfile" option for setting new logfile's name
References: bnc#1020870
Now it's possible to set your own lofile name with
this option ONLY. It fixes API of old versions.
Signed-off-by: Alexander Naumov <alexander_naumov@opensuse.org>
---
diff --git a/src/doc/screen.1 b/src/doc/screen.1
index 23b4d7b..5b14d91 100644
--- doc/screen.1
+++ doc/screen.1
@@ -261,9 +261,12 @@ Ask your system administrator if you are not sure. Remove sessions with the
.B \-L
tells
.I screen
-to turn on automatic output logging for the windows. By default, logfile's name
-is screenlog.1. You can sets new name: add it right after -L option e.g. "screen
--L my_logfile".
+to turn on automatic output logging for the windows.
+.TP 5
+.BI "\-L logfile " file
+By default logfile name is \*Qscreenlog.0\*Q. You can also set new logfile name
+with the \*Qlogfile\*Q option. Keep in mind that logfile name can not start with
+the "-" symbol.
.TP 5
.B \-m
causes
diff --git a/src/screen.c b/src/screen.c
index 64650e9..9e1072a 100644
--- screen.c
+++ screen.c
@@ -302,7 +302,7 @@ struct passwd *ppp;
pw_try_again:
#endif
n = 0;
- if (ppp->pw_passwd[0] == '#' && ppp->pw_passwd[1] == '#' & strcmp(ppp->pw_passwd + 2, ppp->pw_name) == 0)
+ if (ppp->pw_passwd[0] == '#' && ppp->pw_passwd[1] == '#' && strcmp(ppp->pw_passwd + 2, ppp->pw_name) == 0)
n = 13;
for (; n < 13; n++) {
char c = ppp->pw_passwd[n];
@@ -667,18 +667,16 @@ int main(int ac, char** av)
break;
case 'L':
- if (--ac != 0) {
- screenlogfile = SaveStr(*++av);
- if (screenlogfile[0] == '-')
+ if (--ac > 0 && !strcmp(*++av, "logfile")) {
+ *++av; // Now '*av' is a logfile parameter
+
+ 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(screenlogfile) > PATH_MAX)
- Panic(0, "-L: logfile name too long. (max. %d char)", PATH_MAX);
-
- FILE *w_check;
- if ((w_check = fopen(screenlogfile, "w")) == NULL)
- Panic(0, "-L: logfile name access problem");
- else
- fclose(w_check);
+
+ screenlogfile = SaveStr(*av);
}
nwin_options.Lflag = 1;
break;