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
4 /* If true, change some environment vars to indicate the user su'd to. */
5 static bool change_environment;
7 +/* If true, then don't call setsid() with a command. */
10 static struct option const longopts[] =
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'},
18 if (child == 0) { /* child shell */
27 sigemptyset(&action.sa_mask);
30 - if (sigaddset(&ourset, SIGTERM)
31 - || sigaddset(&ourset, SIGALRM)
32 - || sigaction(SIGTERM, &action, NULL)
33 - || sigprocmask(SIG_UNBLOCK, &ourset, NULL)) {
36 + if (sigaddset(&ourset, SIGINT) || sigaddset(&ourset, SIGQUIT))
38 + fprintf(stderr, "%s: signal masking malfunction\n", PROGRAM_NAME);
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);
49 + if (!caught && !same_session && (sigaction(SIGINT, &action, NULL)
50 + || sigaction(SIGQUIT, &action, NULL)))
52 + fprintf(stderr, "%s: signal masking malfunction\n", PROGRAM_NAME);
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\
69 const char *new_user = DEFAULT_USER;
71 + int request_same_session = 0;
74 struct passwd pw_copy;
81 + request_same_session = 1;
91 + if (request_same_session || !command || !pw->pw_uid)
94 if (!shell && !change_environment)
95 shell = getenv ("SHELL");
96 if (shell && getuid () != 0 && restricted_shell (pw->pw_shell))