FreeBSD Bugzilla – Attachment 144711 Details for
Bug 191884
[PATCH] teach chown and chmod about SIGINFO
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
chown patch with updated manage
chown-siginfo.patch (text/plain), 3.80 KB, created by
Dan McGregor
on 2014-07-16 03:39:30 UTC
(
hide
)
Description:
chown patch with updated manage
Filename:
MIME Type:
Creator:
Dan McGregor
Created:
2014-07-16 03:39:30 UTC
Size:
3.80 KB
patch
obsolete
>Index: usr.sbin/chown/chgrp.1 >=================================================================== >--- usr.sbin/chown/chgrp.1 (révision 268715) >+++ usr.sbin/chown/chgrp.1 (copie de travail) >@@ -115,6 +115,17 @@ > .Nm > must belong to the specified group and be the owner of the file, > or be the super-user. >+.Pp >+If >+.Nm >+receives a >+.Dv SIGINFO >+signal (see the >+.Cm status >+argument for >+.Xr stty 1 ) , >+then the current filename as well as the old and new group names are >+displayed. > .Sh FILES > .Bl -tag -width /etc/group -compact > .It Pa /etc/group >Index: usr.sbin/chown/chown.8 >=================================================================== >--- usr.sbin/chown/chown.8 (révision 268715) >+++ usr.sbin/chown/chown.8 (copie de travail) >@@ -134,6 +134,17 @@ > .Pp > The ownership of a file may only be altered by a super-user for > obvious security reasons. >+.Pp >+If >+.Nm >+receives a >+.Dv SIGINFO >+signal (see the >+.Cm status >+argument for >+.Xr stty 1 ) , >+then the current filename as well as the old and new file owner and group >+are displayed. > .Sh EXIT STATUS > .Ex -std > .Sh COMPATIBILITY >Index: usr.sbin/chown/chown.c >=================================================================== >--- usr.sbin/chown/chown.c (révision 268715) >+++ usr.sbin/chown/chown.c (copie de travail) >@@ -51,6 +51,7 @@ > #include <grp.h> > #include <libgen.h> > #include <pwd.h> >+#include <signal.h> > #include <stdint.h> > #include <stdio.h> > #include <stdlib.h> >@@ -62,12 +63,21 @@ > static void chownerr(const char *); > static uid_t id(const char *, const char *); > static void usage(void); >+static void print_info(const FTSENT *, int); > > static uid_t uid; > static gid_t gid; > static int ischown; > static const char *gname; >+static volatile sig_atomic_t siginfo; > >+static void >+siginfo_handler(int sig __unused) >+{ >+ >+ siginfo = 1; >+} >+ > int > main(int argc, char **argv) > { >@@ -118,6 +128,8 @@ > if (argc < 2) > usage(); > >+ (void)signal(SIGINFO, siginfo_handler); >+ > if (Rflag) { > fts_options = FTS_PHYSICAL; > if (hflag && (Hflag || Lflag)) >@@ -184,6 +196,10 @@ > default: > break; > } >+ if (siginfo) { >+ print_info(p, 2); >+ siginfo = 0; >+ } > if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) && > (gid == (gid_t)-1 || gid == p->fts_statp->st_gid)) > continue; >@@ -193,35 +209,8 @@ > rval = 1; > } > } else { >- if (vflag) { >- printf("%s", p->fts_path); >- if (vflag > 1) { >- if (ischown) { >- printf(": %ju:%ju -> %ju:%ju", >- (uintmax_t) >- p->fts_statp->st_uid, >- (uintmax_t) >- p->fts_statp->st_gid, >- (uid == (uid_t)-1) ? >- (uintmax_t) >- p->fts_statp->st_uid : >- (uintmax_t)uid, >- (gid == (gid_t)-1) ? >- (uintmax_t) >- p->fts_statp->st_gid : >- (uintmax_t)gid); >- } else { >- printf(": %ju -> %ju", >- (uintmax_t) >- p->fts_statp->st_gid, >- (gid == (gid_t)-1) ? >- (uintmax_t) >- p->fts_statp->st_gid : >- (uintmax_t)gid); >- } >- } >- printf("\n"); >- } >+ if (vflag) >+ print_info(p, vflag); > } > } > if (errno) >@@ -313,3 +302,36 @@ > "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ..."); > exit(1); > } >+ >+static void >+print_info(const FTSENT *p, int vflag) >+{ >+ >+ printf("%s", p->fts_path); >+ if (vflag > 1) { >+ if (ischown) { >+ printf(": %ju:%ju -> %ju:%ju", >+ (uintmax_t) >+ p->fts_statp->st_uid, >+ (uintmax_t) >+ p->fts_statp->st_gid, >+ (uid == (uid_t)-1) ? >+ (uintmax_t) >+ p->fts_statp->st_uid : >+ (uintmax_t)uid, >+ (gid == (gid_t)-1) ? >+ (uintmax_t) >+ p->fts_statp->st_gid : >+ (uintmax_t)gid); >+ } else { >+ printf(": %ju -> %ju", >+ (uintmax_t) >+ p->fts_statp->st_gid, >+ (gid == (gid_t)-1) ? >+ (uintmax_t) >+ p->fts_statp->st_gid : >+ (uintmax_t)gid); >+ } >+ } >+ printf("\n"); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 191884
:
144693
|
144710
| 144711