From 57bced726f9e1ca99631d657710514fab2af0229 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 21 Nov 2011 13:32:56 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/bash?expand=0&rev=101 --- bash-4.2-endpw.dif | 156 +++++++++++++++++++++++++++++------------ readline-6.2-endpw.dif | 52 ++++++++------ 2 files changed, 143 insertions(+), 65 deletions(-) diff --git a/bash-4.2-endpw.dif b/bash-4.2-endpw.dif index eeeed1bd..fc2f41bf 100644 --- a/bash-4.2-endpw.dif +++ b/bash-4.2-endpw.dif @@ -1,48 +1,58 @@ --- bashline.c -+++ bashline.c 2011-11-11 13:22:00.119146416 +0000 -@@ -2148,10 +2148,10 @@ bash_groupname_completion_function (text - if (gnamelen == 0 || (STREQN (gname, grent->gr_name, gnamelen))) - break; ++++ bashline.c 2011-11-21 12:41:19.831646479 +0000 +@@ -2149,6 +2149,7 @@ bash_groupname_completion_function (text } + + value = savestring (grent->gr_name); + endgrent (); - - if (grent == 0) - { -- endgrent (); - return ((char *)NULL); - } - + return (value); + #endif + } --- examples/loadables/finfo.c -+++ examples/loadables/finfo.c 2011-11-11 13:21:12.319218165 +0000 -@@ -269,9 +269,11 @@ struct stat *st; - printmode((int) st->st_mode); - printf("Link count: %d\n", (int) st->st_nlink); ++++ examples/loadables/finfo.c 2011-11-21 12:23:17.331147246 +0000 +@@ -269,6 +269,7 @@ struct stat *st; pw = getpwuid(st->st_uid); -+ endpwent(); owner = pw ? pw->pw_name : "unknown"; printf("Uid of owner: %d (%s)\n", (int) st->st_uid, owner); ++ endpwent(); gr = getgrgid(st->st_gid); -+ endgrent(); owner = gr ? gr->gr_name : "unknown"; printf("Gid of owner: %d (%s)\n", (int) st->st_gid, owner); - printf("Device type: %d\n", (int) st->st_rdev); -@@ -348,12 +350,14 @@ int flags; +@@ -277,6 +278,7 @@ struct stat *st; + printf("File last access time: %s", ctime (&st->st_atime)); + printf("File last modify time: %s", ctime (&st->st_mtime)); + printf("File last status change time: %s", ctime (&st->st_ctime)); ++ endgrent(); + fflush(stdout); + return(0); + } +@@ -345,16 +347,18 @@ int flags; + else if (flags & OPT_PMASK) printf("%o\n", getperm(st->st_mode) & pmask); else if (flags & OPT_UID) { - pw = getpwuid(st->st_uid); -+ endpwent(); - if (flags & OPT_ASCII) +- pw = getpwuid(st->st_uid); +- if (flags & OPT_ASCII) ++ if (flags & OPT_ASCII) { ++ pw = getpwuid(st->st_uid); printf("%s\n", pw ? pw->pw_name : "unknown"); - else +- else ++ endpwent(); ++ } else printf("%d\n", st->st_uid); } else if (flags & OPT_GID) { - gr = getgrgid(st->st_gid); -+ endgrent(); - if (flags & OPT_ASCII) +- gr = getgrgid(st->st_gid); +- if (flags & OPT_ASCII) ++ if (flags & OPT_ASCII) { ++ gr = getgrgid(st->st_gid); printf("%s\n", gr ? gr->gr_name : "unknown"); - else +- else ++ endgrent(); ++ } else + printf("%d\n", st->st_gid); + } else if (flags & OPT_SIZE) + printf("%ld\n", (long) st->st_size); --- examples/loadables/id.c -+++ examples/loadables/id.c 2011-11-11 13:19:36.515148229 +0000 ++++ examples/loadables/id.c 2011-11-21 12:39:06.895646231 +0000 @@ -42,6 +42,7 @@ #if !defined (HAVE_GETPW_DECLS) @@ -51,31 +61,72 @@ #endif extern struct group *getgrgid (); -@@ -146,6 +147,7 @@ inituser (uname) +@@ -136,18 +137,26 @@ static int + inituser (uname) + char *uname; + { +- struct passwd *pwd; +- + if (uname) + { ++ struct passwd *pwd; ++ int r; ++ ++ r = 0; + pwd = getpwnam (uname); + if (pwd == 0) + { builtin_error ("%s: no such user", uname); - return -1; +- return -1; ++ r = -1; } +- ruid = euid = pwd->pw_uid; +- rgid = egid = pwd->pw_gid; ++ else ++ { ++ ruid = euid = pwd->pw_uid; ++ rgid = egid = pwd->pw_gid; ++ } + endpwent (); - ruid = euid = pwd->pw_uid; - rgid = egid = pwd->pw_gid; ++ if (r < 0) ++ return r; } -@@ -173,6 +175,7 @@ id_pruser (uid) + else + { +@@ -172,11 +181,12 @@ id_pruser (uid) + { pwd = getpwuid (uid); if (pwd == NULL) - r = 1; +- r = 1; ++ r = 1; ++ else ++ printf ("%s", pwd->pw_name); + endpwent (); } - if (pwd) - printf ("%s", pwd->pw_name); -@@ -197,6 +200,7 @@ id_prgrp (gid) +- if (pwd) +- printf ("%s", pwd->pw_name); +- else ++ if (pwd == NULL) + printf ("%u", (unsigned) uid); + + return r; +@@ -197,11 +207,12 @@ id_prgrp (gid) grp = getgrgid (gid); if (grp == NULL) r = 1; ++ else ++ printf ("%s", grp->gr_name); + endgrent (); } - if (grp) -@@ -307,6 +311,8 @@ id_prall (uname) +- if (grp) +- printf ("%s", grp->gr_name); +- else ++ if (grp == NULL) + printf ("%u", (unsigned) gid); + + return r; +@@ -307,6 +318,8 @@ id_prall (uname) else printf ("(%s)", grp->gr_name); } @@ -85,8 +136,8 @@ return r; } --- lib/tilde/shell.c -+++ lib/tilde/shell.c 2011-11-11 13:12:35.932960442 +0000 -@@ -45,7 +45,12 @@ ++++ lib/tilde/shell.c 2011-11-21 13:07:02.099146925 +0000 +@@ -45,9 +45,18 @@ #include #if !defined (HAVE_GETPW_DECLS) @@ -98,23 +149,38 @@ +# endif #endif /* !HAVE_GETPW_DECLS */ ++#if !defined (savestring) ++# define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) ++#endif /* !savestring */ ++ char * -@@ -62,8 +67,13 @@ get_home_dir () + get_env_value (varname) + char *varname; +@@ -58,12 +67,19 @@ get_env_value (varname) + char * + get_home_dir () + { +- char *home_dir; ++ static char *home_dir; struct passwd *entry; - home_dir = (char *)NULL; +- home_dir = (char *)NULL; ++ if (home_dir) ++ goto out; +#if defined (HAVE_GETPWUID) entry = getpwuid (getuid ()); if (entry) - home_dir = entry->pw_dir; +- home_dir = entry->pw_dir; ++ home_dir = savestring(entry->pw_dir); +#endif +#if defined (HAVE_GETPWENT) + endpwent (); +#endif ++out: return (home_dir); } --- lib/tilde/tilde.c -+++ lib/tilde/tilde.c 2011-11-11 13:10:07.375646928 +0000 ++++ lib/tilde/tilde.c 2011-11-11 13:10:07.000000000 +0000 @@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u # endif # if defined (HAVE_GETPWNAM) diff --git a/readline-6.2-endpw.dif b/readline-6.2-endpw.dif index 2a69e81b..dbe1bbd1 100644 --- a/readline-6.2-endpw.dif +++ b/readline-6.2-endpw.dif @@ -1,5 +1,5 @@ --- lib/readline/complete.c -+++ lib/readline/complete.c 2011-11-11 13:16:05.635147670 +0000 ++++ lib/readline/complete.c 2011-11-21 12:51:35.695646715 +0000 @@ -83,6 +83,7 @@ typedef int QSFUNC (); defined. */ #if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)) @@ -8,25 +8,19 @@ #endif /* HAVE_GETPWENT && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */ /* If non-zero, then this is the address of a function to call when -@@ -2049,12 +2050,12 @@ rl_username_completion_function (text, s - break; - } - #endif -+#if defined (HAVE_GETPWENT) -+ endpwent (); -+#endif +@@ -2068,6 +2069,9 @@ rl_username_completion_function (text, s + if (first_char == '~') + rl_filename_completion_desired = 1; - if (entry == 0) - { --#if defined (HAVE_GETPWENT) -- endpwent (); --#endif - return ((char *)NULL); ++#if defined (HAVE_GETPWENT) ++ endpwent (); ++#endif + return (value); } - else + #endif /* !__WIN32__ && !__OPENNT */ --- lib/readline/shell.c -+++ lib/readline/shell.c 2011-11-11 13:14:02.683147026 +0000 -@@ -61,9 +61,14 @@ ++++ lib/readline/shell.c 2011-11-21 13:08:46.343647023 +0000 +@@ -61,9 +61,18 @@ #include "rlshell.h" #include "xmalloc.h" @@ -40,21 +34,39 @@ +extern void endpwent (); +# endif +#endif /* !HAVE_GETPW_DECLS */ ++ ++#if !defined (savestring) ++# define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x)) ++#endif /* !savestring */ #ifndef NULL # define NULL 0 -@@ -168,6 +173,9 @@ sh_get_home_dir () +@@ -159,15 +168,20 @@ sh_get_env_value (varname) + char * + sh_get_home_dir () + { +- char *home_dir; ++ static char *home_dir; + struct passwd *entry; + +- home_dir = (char *)NULL; ++ if (home_dir) ++ goto out; + #if defined (HAVE_GETPWUID) + entry = getpwuid (getuid ()); if (entry) - home_dir = entry->pw_dir; +- home_dir = entry->pw_dir; ++ home_dir = savestring(entry->pw_dir); #endif +#if defined (HAVE_GETPWENT) + endpwent (); +#endif ++out: return (home_dir); } --- lib/readline/tilde.c -+++ lib/readline/tilde.c 2011-11-11 13:09:48.843646721 +0000 ++++ lib/readline/tilde.c 2011-11-11 13:09:49.000000000 +0000 @@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u # endif # if defined (HAVE_GETPWNAM)