Project

General

Profile

Bug #6126 ยป chown.diff

updated patchset - Richard PALO, 2015-08-15 09:13 PM

View differences:

usr/src/ucbcmd/chown/Makefile
31 31
FILEMODE=	755
32 32

  
33 33
CPPFLAGS += -D_FILE_OFFSET_BITS=64
34
CERRWARN += -_gcc=-Wno-implicit-function-declaration
35
CERRWARN += -_gcc=-Wno-parentheses
36 34
LDFLAGS += $(MAPFILE.NGB:%=-M%)
37 35

  
38 36
.KEEP_STATE:
usr/src/ucbcmd/chown/chown.c
37 37
 * contributors.
38 38
 */
39 39

  
40
#pragma ident	"%Z%%M%	%I%	%E% SMI"
41

  
42 40
/*
43 41
 * chown [-fR] uid[.gid] file ...
44 42
 */
45

  
43
#include <stdlib.h>
46 44
#include <stdio.h>
47 45
#include <ctype.h>
48 46
#include <sys/types.h>
......
50 48
#include <pwd.h>
51 49
#include <dirent.h>
52 50
#include <grp.h>
51
#include <unistd.h>
53 52
#include <errno.h>
54 53

  
55
struct	passwd *pwd;
54
static struct	passwd *pwd;
56 55
struct	passwd *getpwnam();
57
struct	stat stbuf;
58
uid_t	uid;
59
int	status;
60
int	fflag;
61
int	rflag;
62

  
63
void fatal(int, char *, char *);
56
static struct	stat stbuf;
57
static uid_t	uid;
58
static int	status;
59
static int	fflag;
60
static int	rflag;
61

  
62
static int chownr(char *dir, uid_t uid, gid_t gid);
63
static int error(char *fmt, char *a);
64
static int isnumber(char *s);
65
static int Perror(char *s);
66
static void fatal(int, char *, char *);
64 67

  
65 68
int
66 69
main(int argc, char *argv[])
......
94 97
		argv++, argc--;
95 98
	}
96 99
	if (argc < 2) {
97
		fprintf(stderr, "usage: chown [-fR] owner[.group] file ...\n");
100
		(void) fprintf(stderr,
101
		    "usage: chown [-fR] owner[.group] file ...\n");
98 102
		exit(-1);
99 103
	}
100
	gid = -1;
104
	gid = (gid_t)-1;
101 105
	group = strchr(argv[0], '.');
102 106
	if (group != NULL) {
103 107
		*group++ = '\0';
......
157 161
{
158 162
	int c;
159 163

  
160
	while (c = *s++)
164
	while ((c = *s++) != 0)
161 165
		if (!isdigit(c))
162 166
			return (0);
163 167
	return (1);
......
180 184
	if (chown(dir, uid, gid) < 0 && Perror(dir))
181 185
		return (1);
182 186
	if (chdir(dir) < 0) {
183
		Perror(dir);
187
		(void) Perror(dir);
184 188
		return (1);
185 189
	}
186 190
	if ((dirp = opendir(".")) == NULL) {
187
		Perror(dir);
191
		(void) Perror(dir);
188 192
		return (1);
189 193
	}
190 194
	dp = readdir(dirp);
......
207 211
		    (ecode = Perror(dp->d_name)))
208 212
			break;
209 213
	}
210
	closedir(dirp);
214
	(void) closedir(dirp);
211 215
	if (chdir(savedir) < 0)
212 216
		fatal(255, "can't change back to %s", savedir);
213 217
	return (ecode);
......
218 222
{
219 223

  
220 224
	if (!fflag) {
221
		fprintf(stderr, "chown: ");
222
		fprintf(stderr, fmt, a);
223
		putc('\n', stderr);
225
		(void) fprintf(stderr, "chown: ");
226
		/* LINTED: E_SEC_PRINTF_VAR_FMT */
227
		(void) fprintf(stderr, fmt, a);
228
		(void) putc('\n', stderr);
224 229
	}
225 230
	return (!fflag);
226 231
}
......
239 244
{
240 245

  
241 246
	if (!fflag) {
242
		fprintf(stderr, "chown: ");
247
		(void) fprintf(stderr, "chown: ");
243 248
		perror(s);
244 249
	}
245 250
	return (!fflag);
    (1-1/1)