aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Ludd <solar@gentoo.org>2006-10-04 23:42:47 +0000
committerNed Ludd <solar@gentoo.org>2006-10-04 23:42:47 +0000
commit89d3ec9f7fcaeecca4697b975205ea641a39518c (patch)
treea4c7f3735a4fe62c08d720be439532011524f55d /pspax.c
parentmake sure we check QA_EXECSTACKS when .o objects are missing .note.GNU-stack ... (diff)
downloadpax-utils-89d3ec9f7fcaeecca4697b975205ea641a39518c.tar.gz
pax-utils-89d3ec9f7fcaeecca4697b975205ea641a39518c.tar.bz2
pax-utils-89d3ec9f7fcaeecca4697b975205ea641a39518c.zip
- commit partial -u/-g support for user and group names vs just numeric uid/gids. this commit however breaks -u 0 -g 0 and will need to be fixed at a later time.
Diffstat (limited to 'pspax.c')
-rw-r--r--pspax.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/pspax.c b/pspax.c
index 9ef6541..230dcaa 100644
--- a/pspax.c
+++ b/pspax.c
@@ -14,6 +14,7 @@
*/
#include "paxinc.h"
+#include <grp.h>
#ifdef WANT_SYSCAP
# undef _POSIX_SOURCE
@@ -24,7 +25,7 @@
#endif
#define PROC_DIR "/proc"
-static const char *rcsid = "$Id: pspax.c,v 1.31 2006/08/12 16:47:52 solar Exp $";
+static const char *rcsid = "$Id: pspax.c,v 1.32 2006/10/04 23:42:47 solar Exp $";
#define argv0 "pspax"
@@ -418,6 +419,9 @@ static void usage(int status)
static void parseargs(int argc, char *argv[])
{
int flag;
+ struct passwd *pwd = NULL;
+ struct group *gwd = NULL;
+
opterr = 0;
while ((flag=getopt_long(argc, argv, PARSE_FLAGS, long_opts, NULL)) != -1) {
switch (flag) {
@@ -434,12 +438,29 @@ static void parseargs(int argc, char *argv[])
case 'a': show_all = 1; break;
case 'e': show_phdr = 1; break;
case 'p': show_pid = atoi(optarg); break;
- case 'u': show_uid = atoi(optarg); break;
- case 'g': show_gid = atoi(optarg); break;
case 'n': noexec = 1; writeexec = 0; break;
case 'w': noexec = 0; writeexec = 1; break;
case 'v': verbose++; break;
-
+ case 'u':
+ show_uid = atoi(optarg);
+ if (show_uid == 0) {
+ pwd = getpwnam(optarg);
+ if (pwd)
+ show_uid = pwd->pw_uid;
+ else
+ err("unknown uid");
+ }
+ break;
+ case 'g':
+ show_gid = atoi(optarg);
+ if (show_gid == 0) {
+ gwd = getgrnam(optarg);
+ if (gwd)
+ show_gid = gwd->gr_gid;
+ else
+ err("unknown gid");
+ }
+ break;
case ':':
case '?':
warn("Unknown option or missing parameter");