2016-09-16 13:10:58 +02:00
|
|
|
---
|
|
|
|
bashline.c | 1 +
|
|
|
|
examples/loadables/finfo.c | 16 ++++++++++------
|
|
|
|
examples/loadables/id.c | 37 +++++++++++++++++++++++++------------
|
|
|
|
lib/tilde/shell.c | 9 +++++++++
|
|
|
|
lib/tilde/tilde.c | 1 +
|
|
|
|
5 files changed, 46 insertions(+), 18 deletions(-)
|
|
|
|
|
2011-11-11 14:55:13 +01:00
|
|
|
--- bashline.c
|
2011-11-21 14:32:56 +01:00
|
|
|
+++ bashline.c 2011-11-21 12:41:19.831646479 +0000
|
2016-09-16 13:10:58 +02:00
|
|
|
@@ -2485,6 +2485,7 @@ bash_groupname_completion_function (text
|
2011-11-11 14:55:13 +01:00
|
|
|
}
|
|
|
|
|
2011-11-21 14:32:56 +01:00
|
|
|
value = savestring (grent->gr_name);
|
|
|
|
+ endgrent ();
|
|
|
|
return (value);
|
|
|
|
#endif
|
|
|
|
}
|
2011-11-11 14:55:13 +01:00
|
|
|
--- examples/loadables/finfo.c
|
2011-11-21 14:32:56 +01:00
|
|
|
+++ examples/loadables/finfo.c 2011-11-21 12:23:17.331147246 +0000
|
2016-09-16 13:10:58 +02:00
|
|
|
@@ -290,6 +290,7 @@ struct stat *st;
|
2011-11-11 14:55:13 +01:00
|
|
|
pw = getpwuid(st->st_uid);
|
|
|
|
owner = pw ? pw->pw_name : "unknown";
|
|
|
|
printf("Uid of owner: %d (%s)\n", (int) st->st_uid, owner);
|
2011-11-21 14:32:56 +01:00
|
|
|
+ endpwent();
|
2011-11-11 14:55:13 +01:00
|
|
|
gr = getgrgid(st->st_gid);
|
|
|
|
owner = gr ? gr->gr_name : "unknown";
|
|
|
|
printf("Gid of owner: %d (%s)\n", (int) st->st_gid, owner);
|
2016-09-16 13:10:58 +02:00
|
|
|
@@ -298,6 +299,7 @@ struct stat *st;
|
2011-11-21 14:32:56 +01:00
|
|
|
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);
|
|
|
|
}
|
2016-09-16 13:10:58 +02:00
|
|
|
@@ -366,16 +368,18 @@ int flags;
|
2011-11-21 14:32:56 +01:00
|
|
|
else if (flags & OPT_PMASK)
|
2011-11-11 14:55:13 +01:00
|
|
|
printf("%o\n", getperm(st->st_mode) & pmask);
|
|
|
|
else if (flags & OPT_UID) {
|
2011-11-21 14:32:56 +01:00
|
|
|
- pw = getpwuid(st->st_uid);
|
|
|
|
- if (flags & OPT_ASCII)
|
|
|
|
+ if (flags & OPT_ASCII) {
|
|
|
|
+ pw = getpwuid(st->st_uid);
|
2011-11-11 14:55:13 +01:00
|
|
|
printf("%s\n", pw ? pw->pw_name : "unknown");
|
2011-11-21 14:32:56 +01:00
|
|
|
- else
|
|
|
|
+ endpwent();
|
|
|
|
+ } else
|
2011-11-11 14:55:13 +01:00
|
|
|
printf("%d\n", st->st_uid);
|
|
|
|
} else if (flags & OPT_GID) {
|
2011-11-21 14:32:56 +01:00
|
|
|
- gr = getgrgid(st->st_gid);
|
|
|
|
- if (flags & OPT_ASCII)
|
|
|
|
+ if (flags & OPT_ASCII) {
|
|
|
|
+ gr = getgrgid(st->st_gid);
|
2011-11-11 14:55:13 +01:00
|
|
|
printf("%s\n", gr ? gr->gr_name : "unknown");
|
2011-11-21 14:32:56 +01:00
|
|
|
- else
|
|
|
|
+ endgrent();
|
|
|
|
+ } else
|
|
|
|
printf("%d\n", st->st_gid);
|
|
|
|
} else if (flags & OPT_SIZE)
|
|
|
|
printf("%ld\n", (long) st->st_size);
|
2011-11-11 14:55:13 +01:00
|
|
|
--- examples/loadables/id.c
|
2011-11-21 14:32:56 +01:00
|
|
|
+++ examples/loadables/id.c 2011-11-21 12:39:06.895646231 +0000
|
2011-11-11 14:55:13 +01:00
|
|
|
@@ -42,6 +42,7 @@
|
|
|
|
|
|
|
|
#if !defined (HAVE_GETPW_DECLS)
|
|
|
|
extern struct passwd *getpwuid ();
|
|
|
|
+extern void endpwent ();
|
|
|
|
#endif
|
|
|
|
extern struct group *getgrgid ();
|
|
|
|
|
2011-11-21 14:32:56 +01:00
|
|
|
@@ -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)
|
|
|
|
{
|
2011-11-11 14:55:13 +01:00
|
|
|
builtin_error ("%s: no such user", uname);
|
2011-11-21 14:32:56 +01:00
|
|
|
- return -1;
|
|
|
|
+ r = -1;
|
2011-11-11 14:55:13 +01:00
|
|
|
}
|
2011-11-21 14:32:56 +01:00
|
|
|
- ruid = euid = pwd->pw_uid;
|
|
|
|
- rgid = egid = pwd->pw_gid;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ruid = euid = pwd->pw_uid;
|
|
|
|
+ rgid = egid = pwd->pw_gid;
|
|
|
|
+ }
|
2011-11-11 14:55:13 +01:00
|
|
|
+ endpwent ();
|
2011-11-21 14:32:56 +01:00
|
|
|
+ if (r < 0)
|
|
|
|
+ return r;
|
2011-11-11 14:55:13 +01:00
|
|
|
}
|
2011-11-21 14:32:56 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
@@ -172,11 +181,12 @@ id_pruser (uid)
|
|
|
|
{
|
2011-11-11 14:55:13 +01:00
|
|
|
pwd = getpwuid (uid);
|
|
|
|
if (pwd == NULL)
|
2011-11-21 14:32:56 +01:00
|
|
|
- r = 1;
|
|
|
|
+ r = 1;
|
|
|
|
+ else
|
|
|
|
+ printf ("%s", pwd->pw_name);
|
2011-11-11 14:55:13 +01:00
|
|
|
+ endpwent ();
|
|
|
|
}
|
2011-11-21 14:32:56 +01:00
|
|
|
- if (pwd)
|
|
|
|
- printf ("%s", pwd->pw_name);
|
|
|
|
- else
|
|
|
|
+ if (pwd == NULL)
|
|
|
|
printf ("%u", (unsigned) uid);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
@@ -197,11 +207,12 @@ id_prgrp (gid)
|
2011-11-11 14:55:13 +01:00
|
|
|
grp = getgrgid (gid);
|
|
|
|
if (grp == NULL)
|
|
|
|
r = 1;
|
2011-11-21 14:32:56 +01:00
|
|
|
+ else
|
|
|
|
+ printf ("%s", grp->gr_name);
|
2011-11-11 14:55:13 +01:00
|
|
|
+ endgrent ();
|
|
|
|
}
|
|
|
|
|
2011-11-21 14:32:56 +01:00
|
|
|
- if (grp)
|
|
|
|
- printf ("%s", grp->gr_name);
|
|
|
|
- else
|
|
|
|
+ if (grp == NULL)
|
|
|
|
printf ("%u", (unsigned) gid);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
@@ -307,6 +318,8 @@ id_prall (uname)
|
2011-11-11 14:55:13 +01:00
|
|
|
else
|
|
|
|
printf ("(%s)", grp->gr_name);
|
|
|
|
}
|
|
|
|
+ endpwent ();
|
|
|
|
+ endgrent ();
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
--- lib/tilde/shell.c
|
2011-11-21 14:32:56 +01:00
|
|
|
+++ lib/tilde/shell.c 2011-11-21 13:07:02.099146925 +0000
|
|
|
|
@@ -45,9 +45,18 @@
|
2011-11-11 14:55:13 +01:00
|
|
|
#include <pwd.h>
|
|
|
|
|
|
|
|
#if !defined (HAVE_GETPW_DECLS)
|
|
|
|
+# if defined (HAVE_GETPWUID)
|
|
|
|
extern struct passwd *getpwuid ();
|
|
|
|
+# endif
|
|
|
|
+# if defined (HAVE_GETPWENT)
|
|
|
|
+extern void endpwent ();
|
|
|
|
+# endif
|
|
|
|
#endif /* !HAVE_GETPW_DECLS */
|
|
|
|
|
2011-11-21 14:32:56 +01:00
|
|
|
+#if !defined (savestring)
|
|
|
|
+# define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
|
|
|
|
+#endif /* !savestring */
|
|
|
|
+
|
|
|
|
char *
|
|
|
|
get_env_value (varname)
|
|
|
|
char *varname;
|
2011-11-11 14:55:13 +01:00
|
|
|
--- lib/tilde/tilde.c
|
2011-11-21 14:32:56 +01:00
|
|
|
+++ lib/tilde/tilde.c 2011-11-11 13:10:07.000000000 +0000
|
2011-11-11 14:55:13 +01:00
|
|
|
@@ -61,6 +61,7 @@ extern struct passwd *getpwuid PARAMS((u
|
|
|
|
# endif
|
|
|
|
# if defined (HAVE_GETPWNAM)
|
|
|
|
extern struct passwd *getpwnam PARAMS((const char *));
|
|
|
|
+extern void endpwent ();
|
|
|
|
# endif
|
|
|
|
#endif /* !HAVE_GETPW_DECLS */
|
|
|
|
|