From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 29 15:00:23 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 091E716A466 for ; Thu, 29 Sep 2005 15:00:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 59ED543D4C for ; Thu, 29 Sep 2005 15:00:22 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j8TF0MHf051459 for ; Thu, 29 Sep 2005 15:00:22 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j8TF0MwZ051453; Thu, 29 Sep 2005 15:00:22 GMT (envelope-from gnats) Resent-Date: Thu, 29 Sep 2005 15:00:22 GMT Resent-Message-Id: <200509291500.j8TF0MwZ051453@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Marcus Alves Grando Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4310A16A41F for ; Thu, 29 Sep 2005 14:50:37 +0000 (GMT) (envelope-from root@marcus.grupos.com.br) Received: from mail.grupos.com.br (mail.grupos.com.br [200.203.183.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id ABAC043D48 for ; Thu, 29 Sep 2005 14:50:36 +0000 (GMT) (envelope-from root@marcus.grupos.com.br) Received: from corp.grupos.com.br (unknown [150.162.166.55]) by mail.grupos.com.br (Postfix) with ESMTP id B761B11E44A for ; Thu, 29 Sep 2005 11:50:32 -0300 (BRT) Received: from marcus.grupos.com.br (unknown [150.162.166.51]) by corp.grupos.com.br (Postfix) with ESMTP id 7F0D85505 for ; Thu, 29 Sep 2005 11:50:32 -0300 (BRT) Received: by marcus.grupos.com.br (Postfix, from userid 0) id 4D9E319; Thu, 29 Sep 2005 11:50:32 -0300 (BRT) Message-Id: <20050929145032.4D9E319@marcus.grupos.com.br> Date: Thu, 29 Sep 2005 11:50:32 -0300 (BRT) From: Marcus Alves Grando To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/86710: Update bin/ls to have option to cancel -A with super user X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Marcus Alves Grando List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Sep 2005 15:00:23 -0000 >Number: 86710 >Category: bin >Synopsis: Update bin/ls to have option to cancel -A with super user >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Thu Sep 29 15:00:21 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Marcus Alves Grando >Release: FreeBSD 6.0-BETA5 i386 >Organization: >Environment: System: FreeBSD marcus.grupos.com.br 6.0-BETA5 FreeBSD 6.0-BETA5 #14: Wed Sep 28 12:52:25 BRT 2005 root@marcus.grupos.com.br:/space/obj/usr/src/sys/MARCUS i386 >Description: Update bin/ls to have option to cancel -A with super user >How-To-Repeat: >Fix: --- ls.patch begins here --- Index: ls.1 =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.1,v retrieving revision 1.91 diff -u -r1.91 ls.1 --- ls.1 6 Sep 2005 20:14:39 -0000 1.91 +++ ls.1 29 Sep 2005 04:21:49 -0000 @@ -40,7 +40,7 @@ .Nd list directory contents .Sh SYNOPSIS .Nm -.Op Fl ABCFGHLPRSTWZabcdfghiklmnopqrstuwx1 +.Op Fl ABCFGHILPRSTWZabcdfghiklmnopqrstuwx1 .Op Ar .Sh DESCRIPTION For each operand that names a @@ -73,6 +73,8 @@ and .Pa .. . Always set for the super-user. +.Fl I +cancel this option. .It Fl B Force printing of non-printable characters (as defined by .Xr ctype 3 @@ -117,6 +119,12 @@ or .Fl l options are specified. +.It Fl I +This option cancels the +.Fl A +option. Usually used by super user when +.Fl A +is not necessary. .It Fl L If argument is a symbolic link, list the file or directory the link references rather than the link itself. Index: ls.c =================================================================== RCS file: /home/ncvs/src/bin/ls/ls.c,v retrieving revision 1.80 diff -u -r1.80 ls.c --- ls.c 3 Jun 2005 11:05:58 -0000 1.80 +++ ls.c 29 Sep 2005 04:21:49 -0000 @@ -110,6 +110,8 @@ static int f_kblocks; /* print size in kilobytes */ static int f_listdir; /* list actual directory, not contents */ static int f_listdot; /* list files beginning with . */ +static int f_nolistdot; /* don't list files beginning with . */ +static int f_forcelistdot; /* force list files beginning with . */ int f_longform; /* long listing format */ int f_nonprint; /* show unprintables as ? */ static int f_nosort; /* don't sort output */ @@ -175,13 +177,9 @@ termwidth = atoi(p); } - /* Root is -A automatically. */ - if (!getuid()) - f_listdot = 1; - fts_options = FTS_PHYSICAL; while ((ch = getopt(argc, argv, - "1ABCFGHLPRSTWZabcdfghiklmnopqrstuwx")) != -1) { + "1ABCFGHILPRSTWZabcdfghiklmnopqrstuwx")) != -1) { switch (ch) { /* * The -1, -C, -x and -l options all override each other so @@ -243,10 +241,14 @@ break; case 'a': fts_options |= FTS_SEEDOT; - /* FALLTHROUGH */ + f_forcelistdot = 1; + break; case 'A': f_listdot = 1; break; + case 'I': + f_nolistdot = 1; + break; /* The -d option turns off the -R option. */ case 'd': f_listdir = 1; @@ -326,6 +328,10 @@ argc -= optind; argv += optind; + /* Root is -A automatically. */ + if (!getuid() && !f_nolistdot) + f_listdot = 1; + /* Enabling of colours is conditional on the environment. */ if (getenv("CLICOLOR") && (isatty(STDOUT_FILENO) || getenv("CLICOLOR_FORCE"))) @@ -490,7 +496,8 @@ break; case FTS_D: if (p->fts_level != FTS_ROOTLEVEL && - p->fts_name[0] == '.' && !f_listdot) + p->fts_name[0] == '.' && ((!f_listdot || + f_nolistdot) && !f_forcelistdot)) break; /* @@ -650,7 +657,8 @@ } } else { /* Only display dot file if -a/-A set. */ - if (cur->fts_name[0] == '.' && !f_listdot) { + if (cur->fts_name[0] == '.' && ((!f_listdot || + f_nolistdot) && !f_forcelistdot)) { cur->fts_number = NO_PRINT; continue; } --- ls.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: