3
0
forked from pool/coreutils
coreutils/coreutils-5.3.0-sbin4su.patch

146 lines
3.1 KiB
Diff
Raw Normal View History

Index: src/su.c
===================================================================
- Update to 8.5: Bug fixes * cp and mv once again support preserving extended attributes. * cp now preserves "capabilities" when also preserving file ownership.7 * ls --color once again honors the 'NORMAL' dircolors directive. [bug introduced in coreutils-6.11] * sort -M now handles abbreviated months that are aligned using blanks in the locale database. Also locales with 8 bit characters are handled correctly, including multi byte locales with the caveat that multi byte characters are matched case sensitively. * sort again handles obsolescent key formats (+POS -POS) correctly. Previously if -POS was specified, 1 field too many was used in the sort. [bug introduced in coreutils-7.2] New features * join now accepts the --header option, to treat the first line of each file as a header line to be joined and printed unconditionally. * timeout now accepts the --kill-after option which sends a kill signal to the monitored command if it's still running the specified duration after the initial signal was sent. * who: the "+/-" --mesg (-T) indicator of whether a user/tty is accepting messages could be incorrectly listed as "+", when in fact, the user was not accepting messages (mesg no). Before, who would examine only the permission bits, and not consider the group of the TTY device file. Thus, if a login tty's group would change somehow e.g., to "root", that would make it unwritable (via write(1)) by normal users, in spite of whatever the permission bits might imply. Now, when configured using the --with-tty-group[=NAME] option, who also compares the group of the TTY device with NAME (or "tty" if no group name is specified). Changes in behavior * ls --color no longer emits the final 3-byte color-resetting escape sequence when it would be a no-op. * join -t '' no longer emits an error and instead operates on each line as a whole (even if they contain NUL characters). For other changes since 7.1 see NEWS. - Split-up coreutils-%%{version}.diff as far as possible. - Prefix all patches with coreutils-. - All patches have the .patch suffix. - Use the i18n patch from Archlinux as it fixes at least one test suite failure. OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=9
2010-05-07 17:54:35 +02:00
--- src/su.c.orig 2010-05-05 14:46:48.000000000 +0200
+++ src/su.c 2010-05-05 14:48:55.023359308 +0200
@@ -454,6 +454,117 @@ correct_password (const struct passwd *p
#endif /* !USE_PAM */
}
+/* Add or clear /sbin and /usr/sbin for the su command
+ used without `-'. */
+
+/* Set if /sbin is found in path. */
+#define SBIN_MASK 0x01
+/* Set if /usr/sbin is found in path. */
+#define USBIN_MASK 0x02
+
+static char *
+addsbin (const char *const path)
+{
+ unsigned char smask = 0;
+ char *ptr, *tmp, *cur, *ret = NULL;
+ size_t len;
+
+ if (!path || *path == 0)
+ return NULL;
+
+ tmp = xstrdup (path);
+ cur = tmp;
+ for (ptr = strsep (&cur, ":"); ptr != NULL; ptr = strsep (&cur, ":"))
+ {
+ if (!strcmp (ptr, "/sbin"))
+ smask |= SBIN_MASK;
+ if (!strcmp (ptr, "/usr/sbin"))
+ smask |= USBIN_MASK;
+ }
+
+ if ((smask & (USBIN_MASK|SBIN_MASK)) == (USBIN_MASK|SBIN_MASK))
+ {
+ free (tmp);
+ return NULL;
+ }
+
+ len = strlen (path);
+ if (!(smask & USBIN_MASK))
+ len += strlen ("/usr/sbin:");
+
+ if (!(smask & SBIN_MASK))
+ len += strlen (":/sbin");
+
+ ret = xmalloc (len + 1);
+ strcpy (tmp, path);
+
+ *ret = 0;
+ cur = tmp;
+ for (ptr = strsep (&cur, ":"); ptr; ptr = strsep (&cur, ":"))
+ {
+ if (!strcmp (ptr, "."))
+ continue;
+ if (*ret)
+ strcat (ret, ":");
+ if (!(smask & USBIN_MASK) && !strcmp (ptr, "/bin"))
+ {
+ strcat (ret, "/usr/sbin:");
+ strcat (ret, ptr);
+ smask |= USBIN_MASK;
+ continue;
+ }
+ if (!(smask & SBIN_MASK) && !strcmp (ptr, "/usr/bin"))
+ {
+ strcat (ret, ptr);
+ strcat (ret, ":/sbin");
+ smask |= SBIN_MASK;
+ continue;
+ }
+ strcat (ret, ptr);
+ }
+ free (tmp);
+
+ if (!(smask & USBIN_MASK))
+ strcat (ret, ":/usr/sbin");
+
+ if (!(smask & SBIN_MASK))
+ strcat (ret, ":/sbin");
+
+ return ret;
+}
+
+static char *
+clearsbin (const char *const path)
+{
+ char *ptr, *tmp, *cur, *ret = NULL;
+
+ if (!path || *path == 0)
+ return NULL;
+
+ tmp = strdup (path);
+ if (!tmp)
+ return NULL;
+
+ ret = xmalloc (strlen (path) + 1);
+ *ret = 0;
+ cur = tmp;
+ for (ptr = strsep (&cur, ":"); ptr; ptr = strsep (&cur, ":"))
+ {
+ if (!strcmp (ptr, "/sbin"))
+ continue;
+ if (!strcmp (ptr, "/usr/sbin"))
+ continue;
+ if (!strcmp (ptr, "/usr/local/sbin"))
+ continue;
+ if (*ret)
+ strcat (ret, ":");
+ strcat (ret, ptr);
+ }
+ free (tmp);
+
+ return ret;
+}
+
/* Update `environ' for the new shell based on PW, with SHELL being
the value for the SHELL environment variable. */
- Update to 8.5: Bug fixes * cp and mv once again support preserving extended attributes. * cp now preserves "capabilities" when also preserving file ownership.7 * ls --color once again honors the 'NORMAL' dircolors directive. [bug introduced in coreutils-6.11] * sort -M now handles abbreviated months that are aligned using blanks in the locale database. Also locales with 8 bit characters are handled correctly, including multi byte locales with the caveat that multi byte characters are matched case sensitively. * sort again handles obsolescent key formats (+POS -POS) correctly. Previously if -POS was specified, 1 field too many was used in the sort. [bug introduced in coreutils-7.2] New features * join now accepts the --header option, to treat the first line of each file as a header line to be joined and printed unconditionally. * timeout now accepts the --kill-after option which sends a kill signal to the monitored command if it's still running the specified duration after the initial signal was sent. * who: the "+/-" --mesg (-T) indicator of whether a user/tty is accepting messages could be incorrectly listed as "+", when in fact, the user was not accepting messages (mesg no). Before, who would examine only the permission bits, and not consider the group of the TTY device file. Thus, if a login tty's group would change somehow e.g., to "root", that would make it unwritable (via write(1)) by normal users, in spite of whatever the permission bits might imply. Now, when configured using the --with-tty-group[=NAME] option, who also compares the group of the TTY device with NAME (or "tty" if no group name is specified). Changes in behavior * ls --color no longer emits the final 3-byte color-resetting escape sequence when it would be a no-op. * join -t '' no longer emits an error and instead operates on each line as a whole (even if they contain NUL characters). For other changes since 7.1 see NEWS. - Split-up coreutils-%%{version}.diff as far as possible. - Prefix all patches with coreutils-. - All patches have the .patch suffix. - Use the i18n patch from Archlinux as it fixes at least one test suite failure. OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=9
2010-05-07 17:54:35 +02:00
@@ -493,6 +604,22 @@ modify_environment (const struct passwd
DEFAULT_LOGIN_PATH)
: getdef_str ("SUPATH",
DEFAULT_ROOT_LOGIN_PATH)));
+ else
+ {
+ char const *path = getenv ("PATH");
+ char *new = NULL;
+
+ if (pw->pw_uid)
+ new = clearsbin (path);
+ else
+ new = addsbin (path);
+
+ if (new)
+ {
+ xsetenv ("PATH", new);
+ free (new);
+ }
+ }
- Update to 8.5: Bug fixes * cp and mv once again support preserving extended attributes. * cp now preserves "capabilities" when also preserving file ownership.7 * ls --color once again honors the 'NORMAL' dircolors directive. [bug introduced in coreutils-6.11] * sort -M now handles abbreviated months that are aligned using blanks in the locale database. Also locales with 8 bit characters are handled correctly, including multi byte locales with the caveat that multi byte characters are matched case sensitively. * sort again handles obsolescent key formats (+POS -POS) correctly. Previously if -POS was specified, 1 field too many was used in the sort. [bug introduced in coreutils-7.2] New features * join now accepts the --header option, to treat the first line of each file as a header line to be joined and printed unconditionally. * timeout now accepts the --kill-after option which sends a kill signal to the monitored command if it's still running the specified duration after the initial signal was sent. * who: the "+/-" --mesg (-T) indicator of whether a user/tty is accepting messages could be incorrectly listed as "+", when in fact, the user was not accepting messages (mesg no). Before, who would examine only the permission bits, and not consider the group of the TTY device file. Thus, if a login tty's group would change somehow e.g., to "root", that would make it unwritable (via write(1)) by normal users, in spite of whatever the permission bits might imply. Now, when configured using the --with-tty-group[=NAME] option, who also compares the group of the TTY device with NAME (or "tty" if no group name is specified). Changes in behavior * ls --color no longer emits the final 3-byte color-resetting escape sequence when it would be a no-op. * join -t '' no longer emits an error and instead operates on each line as a whole (even if they contain NUL characters). For other changes since 7.1 see NEWS. - Split-up coreutils-%%{version}.diff as far as possible. - Prefix all patches with coreutils-. - All patches have the .patch suffix. - Use the i18n patch from Archlinux as it fixes at least one test suite failure. OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=9
2010-05-07 17:54:35 +02:00
if (pw->pw_uid)
{
xsetenv ("USER", pw->pw_name);