From owner-p4-projects Thu Oct 10 9:33:29 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3146B37B404; Thu, 10 Oct 2002 09:33:24 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BAA5437B401 for ; Thu, 10 Oct 2002 09:33:23 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5D52F43E91 for ; Thu, 10 Oct 2002 09:33:23 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id g9AGX9Mt087969 for ; Thu, 10 Oct 2002 09:33:09 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.3/Submit) id g9AGWt9d087961 for perforce@freebsd.org; Thu, 10 Oct 2002 09:32:55 -0700 (PDT) Date: Thu, 10 Oct 2002 09:32:55 -0700 (PDT) Message-Id: <200210101632.g9AGWt9d087961@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 19032 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/p4db/chv.cgi?CH=19032 Change 19032 by rwatson@rwatson_tislabs on 2002/10/10 09:32:28 Restore consistency with other base system security and non-security attribute management tools. By default, follow symlinks in EA operations; if the -h flag is specified, act on the link instead of the target. Discussed with: phk, others Affected files ... .. //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.8#4 edit .. //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.c#6 edit Differences ... ==== //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.8#4 (text+ko) ==== @@ -42,21 +42,21 @@ .Nd manipulated extended attributes .Sh SYNOPSIS .Nm getextattr -.Op Fl fqsx +.Op Fl fhqsx .Ar attrnamespace .Ar attrname .Ar filename ... .Nm lsextattr -.Op Fl fq +.Op Fl fhq .Ar attrnamespace .Ar filename ... .Nm rmextattr -.Op Fl fq +.Op Fl fhq .Ar attrnamespace .Ar attrname .Ar filename ... .Nm setextattr -.Op Fl fnq +.Op Fl fhnq .Ar attrnamespace .Ar attrname .Ar attrvalue @@ -77,15 +77,15 @@ the name of the target file or directory, .Ar attrvalue a string to store in the attribute. -Since it is not useful to operate on the target of a symbolic link, the given -.Ar filename -is not followed if it is one. .Pp The following options are available: .Bl -tag -width flag .It Fl -f (Force) Ignore errors on individual filenames and continue with the remaining arguments. +.It Fl -h +(No follow) If the file is a symbolic link, perform the operation on the +link itself rather than the file that the link points to. .It Fl -n (Nul-terminate) Nul-terminate the extent content written out. .It Fl -q ==== //depot/projects/trustedbsd/mac/usr.sbin/extattr/rmextattr.c#6 (text+ko) ==== @@ -58,19 +58,19 @@ switch (what) { case EAGET: - fprintf(stderr, "usage: getextattr [-fqsx] attrnamespace"); + fprintf(stderr, "usage: getextattr [-fhqsx] attrnamespace"); fprintf(stderr, " attrname filename ...\n"); exit(-1); case EASET: - fprintf(stderr, "usage: setextattr [-fnq] attrnamespace"); + fprintf(stderr, "usage: setextattr [-fhnq] attrnamespace"); fprintf(stderr, " attrname attrvalue filename ...\n"); exit(-1); case EARM: - fprintf(stderr, "usage: rmextattr [-fq] attrnamespace"); + fprintf(stderr, "usage: rmextattr [-fhq] attrnamespace"); fprintf(stderr, " attrname filename ...\n"); exit(-1); case EALS: - fprintf(stderr, "usage: lsextattr [-fq] attrnamespace"); + fprintf(stderr, "usage: lsextattr [-fhq] attrnamespace"); fprintf(stderr, " filename ...\n"); exit(-1); case EADUNNO: @@ -106,6 +106,7 @@ minargc; int flag_force = 0; + int flag_nofollow = 0; int flag_null = 0; int flag_quiet = 0; int flag_string = 0; @@ -119,19 +120,19 @@ p = argv[0]; if (!strcmp(p, "getextattr")) { what = EAGET; - options = "fqsx"; + options = "fhqsx"; minargc = 3; } else if (!strcmp(p, "setextattr")) { what = EASET; - options = "fnq"; + options = "fhnq"; minargc = 4; } else if (!strcmp(p, "rmextattr")) { what = EARM; - options = "fq"; + options = "fhq"; minargc = 3; } else if (!strcmp(p, "lsextattr")) { what = EALS; - options = "fq"; + options = "fhq"; minargc = 2; } else { usage(); @@ -142,6 +143,9 @@ case 'f': flag_force = 1; break; + case 'h': + flag_nofollow = 1; + break; case 'n': flag_null = 1; break; @@ -187,27 +191,44 @@ for (arg_counter = 0; arg_counter < argc; arg_counter++) { switch (what) { case EARM: - error = extattr_delete_link(argv[arg_counter], - attrnamespace, attrname); + if (flag_nofollow) + error = extattr_delete_link(argv[arg_counter], + attrnamespace, attrname); + else + error = extattr_delete_file(argv[arg_counter], + attrnamespace, attrname); if (error >= 0) continue; break; case EASET: - error = extattr_set_link(argv[arg_counter], - attrnamespace, attrname, buf, - strlen(buf) + flag_null); + if (flag_nofollow) + error = extattr_set_link(argv[arg_counter], + attrnamespace, attrname, buf, + strlen(buf) + flag_null); + else + error = extattr_set_file(argv[arg_counter], + attrnamespace, attrname, buf, + strlen(buf) + flag_null); if (error >= 0) continue; break; case EALS: case EAGET: - error = extattr_get_link(argv[arg_counter], - attrnamespace, attrname, NULL, 0); + if (flag_nofollow) + error = extattr_get_link(argv[arg_counter], + attrnamespace, attrname, NULL, 0); + else + error = extattr_get_file(argv[arg_counter], + attrnamespace, attrname, NULL, 0); if (error < 0) break; mkbuf(&buf, &buflen, error); - error = extattr_get_link(argv[arg_counter], - attrnamespace, attrname, buf, buflen); + if (flag_nofollow) + error = extattr_get_link(argv[arg_counter], + attrnamespace, attrname, buf, buflen); + else + error = extattr_get_file(argv[arg_counter], + attrnamespace, attrname, buf, buflen); if (error < 0) break; if (!flag_quiet) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message