View | Details | Raw Unified | Return to bug 191884 | Differences between
and this patch

Collapse All | Expand All

(-)usr.sbin/chown/chgrp.1 (+11 lines)
Lines 115-120 Link Here
115
.Nm
115
.Nm
116
must belong to the specified group and be the owner of the file,
116
must belong to the specified group and be the owner of the file,
117
or be the super-user.
117
or be the super-user.
118
.Pp
119
If
120
.Nm
121
receives a
122
.Dv SIGINFO
123
signal (see the
124
.Cm status
125
argument for
126
.Xr stty 1 ) ,
127
then the current filename as well as the old and new group names are
128
displayed.
118
.Sh FILES
129
.Sh FILES
119
.Bl -tag -width /etc/group -compact
130
.Bl -tag -width /etc/group -compact
120
.It Pa /etc/group
131
.It Pa /etc/group
(-)usr.sbin/chown/chown.8 (+11 lines)
Lines 134-139 Link Here
134
.Pp
134
.Pp
135
The ownership of a file may only be altered by a super-user for
135
The ownership of a file may only be altered by a super-user for
136
obvious security reasons.
136
obvious security reasons.
137
.Pp
138
If
139
.Nm
140
receives a
141
.Dv SIGINFO
142
signal (see the
143
.Cm status
144
argument for
145
.Xr stty 1 ) ,
146
then the current filename as well as the old and new file owner and group
147
are displayed.
137
.Sh EXIT STATUS
148
.Sh EXIT STATUS
138
.Ex -std
149
.Ex -std
139
.Sh COMPATIBILITY
150
.Sh COMPATIBILITY
(-)usr.sbin/chown/chown.c (-29 / +51 lines)
Lines 51-56 Link Here
51
#include <grp.h>
51
#include <grp.h>
52
#include <libgen.h>
52
#include <libgen.h>
53
#include <pwd.h>
53
#include <pwd.h>
54
#include <signal.h>
54
#include <stdint.h>
55
#include <stdint.h>
55
#include <stdio.h>
56
#include <stdio.h>
56
#include <stdlib.h>
57
#include <stdlib.h>
Lines 62-73 Link Here
62
static void	chownerr(const char *);
63
static void	chownerr(const char *);
63
static uid_t	id(const char *, const char *);
64
static uid_t	id(const char *, const char *);
64
static void	usage(void);
65
static void	usage(void);
66
static void	print_info(const FTSENT *, int);
65
67
66
static uid_t uid;
68
static uid_t uid;
67
static gid_t gid;
69
static gid_t gid;
68
static int ischown;
70
static int ischown;
69
static const char *gname;
71
static const char *gname;
72
static volatile sig_atomic_t siginfo;
70
73
74
static void
75
siginfo_handler(int sig __unused)
76
{
77
78
	siginfo = 1;
79
}
80
71
int
81
int
72
main(int argc, char **argv)
82
main(int argc, char **argv)
73
{
83
{
Lines 118-123 Link Here
118
	if (argc < 2)
128
	if (argc < 2)
119
		usage();
129
		usage();
120
130
131
	(void)signal(SIGINFO, siginfo_handler);
132
121
	if (Rflag) {
133
	if (Rflag) {
122
		fts_options = FTS_PHYSICAL;
134
		fts_options = FTS_PHYSICAL;
123
		if (hflag && (Hflag || Lflag))
135
		if (hflag && (Hflag || Lflag))
Lines 184-189 Link Here
184
		default:
196
		default:
185
			break;
197
			break;
186
		}
198
		}
199
		if (siginfo) {
200
			print_info(p, 2);
201
			siginfo = 0;
202
		}
187
		if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) &&
203
		if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) &&
188
		    (gid == (gid_t)-1 || gid == p->fts_statp->st_gid))
204
		    (gid == (gid_t)-1 || gid == p->fts_statp->st_gid))
189
			continue;
205
			continue;
Lines 193-227 Link Here
193
				rval = 1;
209
				rval = 1;
194
			}
210
			}
195
		} else {
211
		} else {
196
			if (vflag) {
212
			if (vflag)
197
				printf("%s", p->fts_path);
213
				print_info(p, vflag);
198
				if (vflag > 1) {
199
					if (ischown) {
200
						printf(": %ju:%ju -> %ju:%ju",
201
						    (uintmax_t)
202
						    p->fts_statp->st_uid, 
203
						    (uintmax_t)
204
						    p->fts_statp->st_gid,
205
						    (uid == (uid_t)-1) ? 
206
						    (uintmax_t)
207
						    p->fts_statp->st_uid : 
208
						    (uintmax_t)uid,
209
						    (gid == (gid_t)-1) ? 
210
						    (uintmax_t)
211
						    p->fts_statp->st_gid :
212
						    (uintmax_t)gid);
213
					} else {
214
						printf(": %ju -> %ju",
215
						    (uintmax_t)
216
						    p->fts_statp->st_gid,
217
						    (gid == (gid_t)-1) ? 
218
						    (uintmax_t)
219
						    p->fts_statp->st_gid : 
220
						    (uintmax_t)gid);
221
					}
222
				}
223
				printf("\n");
224
			}
225
		}
214
		}
226
	}
215
	}
227
	if (errno)
216
	if (errno)
Lines 313-315 Link Here
313
		    "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ...");
302
		    "usage: chgrp [-fhvx] [-R [-H | -L | -P]] group file ...");
314
	exit(1);
303
	exit(1);
315
}
304
}
305
306
static void
307
print_info(const FTSENT *p, int vflag)
308
{
309
310
	printf("%s", p->fts_path);
311
	if (vflag > 1) {
312
		if (ischown) {
313
			printf(": %ju:%ju -> %ju:%ju",
314
					(uintmax_t)
315
					p->fts_statp->st_uid, 
316
					(uintmax_t)
317
					p->fts_statp->st_gid,
318
					(uid == (uid_t)-1) ? 
319
					(uintmax_t)
320
					p->fts_statp->st_uid : 
321
					(uintmax_t)uid,
322
					(gid == (gid_t)-1) ? 
323
					(uintmax_t)
324
					p->fts_statp->st_gid :
325
					(uintmax_t)gid);
326
		} else {
327
			printf(": %ju -> %ju",
328
					(uintmax_t)
329
					p->fts_statp->st_gid,
330
					(gid == (gid_t)-1) ? 
331
					(uintmax_t)
332
					p->fts_statp->st_gid : 
333
					(uintmax_t)gid);
334
		}
335
	}
336
	printf("\n");
337
}

Return to bug 191884