[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: permissions/sudo/sudoers



Bob Proulx <bob@proulx.com> wrote:
> In the case of the recent sudo there is the /etc/sudoers.d/* files and
> I always create a new uniquely named local file there for my
> configuration and I no longer edit the /etc/sudoers file.  This is
> also a pain because it means I can't use the default 'visudo' to edit
> the file.

Either create this as a visudo script somewhere in your PATH, such as
in /usr/local/bin/ (but don't replace /usr/sbin/visudo):

    #!/bin/sh
    #	vidudo
    #	visudo -
    #	visudo /etc/sudoers.d/...
    LOCAL=/etc/sudoers.d/`hostname`
    test 1 -eq $# -a X- = "X$1" && shift && LOCAL=
    test 0 -eq $# && set -- "$LOCAL"
    exec /usr/sbin/visudo "$@" 

Or create a simple shell function (works in bash) - notice it includes
the sudo verb, though, and doesn't provide for editing of the default
file except by explicit file path:

    visudo() { sudo /usr/sbin/visudo "${@:-/etc/sudoers.d/`hostname`}"; }


I'm sure you'll have your equivalents, but these could work for me.
Chris


Reply to: