/[pkgs]/devel/coreutils/coreutils-setsid.patch
ViewVC logotype

Contents of /devel/coreutils/coreutils-setsid.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download) (as text)
Sat Sep 12 09:28:49 2009 UTC (2 months, 1 week ago) by ovasik
Branch: MAIN
CVS Tags: coreutils-7_6-4_fc12, coreutils-7_6-5_fc12, coreutils-7_6-7_fc13, coreutils-7_6-2_fc12, coreutils-8_0-1_fc13, F-12-split, coreutils-7_6-3_fc12, coreutils-8_0-2_fc13, coreutils-7_6-6_fc13, coreutils-7_6-6_fc12, coreutils-7_6-1_fc12, HEAD
Changes since 1.3: +20 -20 lines
File MIME type: text/x-patch
new upstream bugfix release 7.6, removed applied patches,defuzzed the rest
1 --- coreutils-6.7/src/su.c.setsid 2007-01-09 17:26:26.000000000 +0000
2 +++ coreutils-6.7/src/su.c 2007-01-09 17:26:57.000000000 +0000
3 @@ -176,9 +176,13 @@
4 /* If true, change some environment vars to indicate the user su'd to. */
5 static bool change_environment;
6
7 +/* If true, then don't call setsid() with a command. */
8 +int same_session = 0;
9 +
10 static struct option const longopts[] =
11 {
12 {"command", required_argument, NULL, 'c'},
13 + {"session-command", required_argument, NULL, 'C'},
14 {"fast", no_argument, NULL, 'f'},
15 {"login", no_argument, NULL, 'l'},
16 {"preserve-environment", no_argument, NULL, 'p'},
17 @@ -478,6 +482,8 @@
18 if (child == 0) { /* child shell */
19 change_identity (pw);
20 pam_end(pamh, 0);
21 + if (!same_session)
22 + setsid ();
23 #endif
24
25 if (simulate_login)
26 @@ -532,13 +538,27 @@
27 sigemptyset(&action.sa_mask);
28 action.sa_flags = 0;
29 sigemptyset(&ourset);
30 - if (sigaddset(&ourset, SIGTERM)
31 - || sigaddset(&ourset, SIGALRM)
32 - || sigaction(SIGTERM, &action, NULL)
33 - || sigprocmask(SIG_UNBLOCK, &ourset, NULL)) {
34 + if (!same_session)
35 + {
36 + if (sigaddset(&ourset, SIGINT) || sigaddset(&ourset, SIGQUIT))
37 + {
38 + fprintf(stderr, "%s: signal masking malfunction\n", PROGRAM_NAME);
39 + caught = 1;
40 + }
41 + }
42 + if (!caught && (sigaddset(&ourset, SIGTERM)
43 + || sigaddset(&ourset, SIGALRM)
44 + || sigaction(SIGTERM, &action, NULL)
45 + || sigprocmask(SIG_UNBLOCK, &ourset, NULL))) {
46 fprintf(stderr, "%s: signal masking malfunction\n", PROGRAM_NAME);
47 caught = 1;
48 }
49 + if (!caught && !same_session && (sigaction(SIGINT, &action, NULL)
50 + || sigaction(SIGQUIT, &action, NULL)))
51 + {
52 + fprintf(stderr, "%s: signal masking malfunction\n", PROGRAM_NAME);
53 + caught = 1;
54 + }
55 }
56 if (!caught) {
57 do {
58 @@ -609,6 +629,8 @@
59 \n\
60 -, -l, --login make the shell a login shell\n\
61 -c, --command=COMMAND pass a single COMMAND to the shell with -c\n\
62 + --session-command=COMMAND pass a single COMMAND to the shell with -c\n\
63 + and do not create a new session\n\
64 -f, --fast pass -f to the shell (for csh or tcsh)\n\
65 -m, --preserve-environment do not reset environment variables\n\
66 -p same as -m\n\
67 @@ -631,6 +653,7 @@
68 int optc;
69 const char *new_user = DEFAULT_USER;
70 char *command = NULL;
71 + int request_same_session = 0;
72 char *shell = NULL;
73 struct passwd *pw;
74 struct passwd pw_copy;
75 @@ -656,6 +679,11 @@
76 command = optarg;
77 break;
78
79 + case 'C':
80 + command = optarg;
81 + request_same_session = 1;
82 + break;
83 +
84 case 'f':
85 fast_startup = true;
86 break;
87 @@ -725,6 +753,9 @@
88 }
89 #endif
90
91 + if (request_same_session || !command || !pw->pw_uid)
92 + same_session = 1;
93 +
94 if (!shell && !change_environment)
95 shell = getenv ("SHELL");
96 if (shell && getuid () != 0 && restricted_shell (pw->pw_shell))

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2