diff options
Diffstat (limited to 'usr/src/cmd/chown')
| -rw-r--r-- | usr/src/cmd/chown/Makefile | 29 | ||||
| -rw-r--r-- | usr/src/cmd/chown/chown.c | 38 |
2 files changed, 20 insertions, 47 deletions
diff --git a/usr/src/cmd/chown/Makefile b/usr/src/cmd/chown/Makefile index 622030cf38..9ee61bfc5f 100644 --- a/usr/src/cmd/chown/Makefile +++ b/usr/src/cmd/chown/Makefile @@ -19,50 +19,37 @@ # CDDL HEADER END # # -#ident "%Z%%M% %I% %E% SMI" -# # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # PROG= chown -XPG4PROG= chown -XD= exobjs.xpg4 EXOBJS= chown.o -XPG4EXOBJS= exobjs.xpg4/chown.o include ../Makefile.cmd -$(XPG4) := CFLAGS += -DXPG4 +ROOTXPG4LINK=$(ROOTXPG4BIN)/$(PROG) + CPPFLAGS += -D_FILE_OFFSET_BITS=64 LDLIBS += -lcmdutils -lsec .KEEP_STATE: -all: $(PROG) $(XPG4) +all: $(PROG) $(PROG): $(EXOBJS) $(LINK.c) -o $@ $(EXOBJS) $(LDLIBS) $(POST_PROCESS) -$(XPG4): $(XD) $(XPG4EXOBJS) - $(LINK.c) -o $@ $(XPG4EXOBJS) $(LDLIBS) - $(POST_PROCESS) - +$(ROOTXPG4LINK): $(ROOTPROG) + -$(RM) $@ + -$(SYMLINK) ../../bin/chown $@ -install: all $(ROOTPROG) $(ROOTXPG4PROG) +install: all $(ROOTPROG) $(ROOTXPG4LINK) clean: - -@rm -rf $(EXOBJS) $(XD) + -@rm -rf $(EXOBJS) lint: lint_PROG -$(XPG4EXOBJS): $(XD) - -$(XD)/%.o: %.c - $(COMPILE.c) -o $@ $< - -$(XD): - -@mkdir -p $@ - include ../Makefile.targ diff --git a/usr/src/cmd/chown/chown.c b/usr/src/cmd/chown/chown.c index 319f571384..4542ab25bf 100644 --- a/usr/src/cmd/chown/chown.c +++ b/usr/src/cmd/chown/chown.c @@ -24,14 +24,16 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Portions of this source code were derived from Berkeley 4.3 BSD * under license from the Regents of the University of California. */ -#pragma ident "%Z%%M% %I% %E% SMI" +/* + * Copyright (c) 2018, Joyent, Inc. + */ /* * chown [-fhR] uid[:gid] file ... @@ -76,41 +78,18 @@ static int isnumber(char *); static void chownr(char *, uid_t, gid_t); static void usage(); -#ifdef XPG4 -/* - * Check to see if we are to follow symlinks specified on the command line. - * This assumes we've already checked to make sure neither -h or -P was - * specified, so we are just looking to see if -R -H, or -R -L was specified, - * or, since -R has the same behavior as -R -L, if -R was specified by itself. - * Therefore, all we really need to check for is if -R was specified. - */ -#define FOLLOW_CL_LINKS (rflag) -#else /* * Check to see if we are to follow symlinks specified on the command line. * This assumes we've already checked to make sure neither -h or -P was * specified, so we are just looking to see if -R -H, or -R -L was specified. - * Note: -R by itself will change the ownership of a directory referenced by a - * symlink however it will now follow the symlink to any other part of the - * file hierarchy. */ #define FOLLOW_CL_LINKS (rflag && (Hflag || Lflag)) -#endif -#ifdef XPG4 -/* - * Follow symlinks when traversing directories. Since -R behaves the - * same as -R -L, we always want to follow symlinks to other parts - * of the file hierarchy unless -H was specified. - */ -#define FOLLOW_D_LINKS (!Hflag) -#else /* * Follow symlinks when traversing directories. Only follow symlinks * to other parts of the file hierarchy if -L was specified. */ #define FOLLOW_D_LINKS (Lflag) -#endif #define CHOWN(f, u, g) if (chown(f, u, g) < 0) { \ status += Perror(f); \ @@ -180,6 +159,13 @@ main(int argc, char *argv[]) } } /* + * Set Pflag by default for recursive operations + * if no other options were specified. + */ + if (rflag && !(Lflag || Hflag || Pflag || hflag)) { + Pflag = 1; + } + /* * Check for sufficient arguments * or a usage error. */ @@ -217,7 +203,7 @@ main(int argc, char *argv[]) if (errno == ERANGE) { (void) fprintf(stderr, gettext( "chown: group id too large\n")); - exit(2); + exit(2); } else { (void) fprintf(stderr, gettext( "chown: invalid group id\n")); |
