Re: SUDOERS: how to setup in a school

From: Chris Cox (ccox_nopenotthis_at_airmail.net)
Date: 10/20/04

  • Next message: pro: "where are logs if any change password?"
    Date: Wed, 20 Oct 2004 16:05:00 -0500
    
    

    Edilmar Alves wrote:
    > Hi,
    >
    > I'm teacher of a Linux course, and I'm using Fedora Core 2 to teach
    > how to configure services like DNS, Apache, Proftp, Postfix, SSH,
    > Samba, NFS and NIS. But, for convenience, the first students have
    > to login using ROOT user or a user created with ROOT privileges,
    > to allow to modify configuration files, and restart services into
    > /etc/rc.d/init.d.
    >
    > However, I'd like to know if it is possible to configure SUDOERS
    > for this situation. There are many config. files to change and many
    > services to start/stop, and I'd like to create "student users"
    > with no ROOT access but with privileges to do these configs.
    > Is it possible? Does someone has some sample of this?

    As a general rule, it's not a great idea... but I understand the
    need. So... here's an sudoers set of commands:

    Cmnd_Alias INIT_SCRIPTS = /etc/init.d/*

    User_Alias INITUSERS = ALL

    INITUSERS ALL = INIT_SCRIPTS

    This will allow any (INITUSERS) to run any script in /etc/init.d/* as
    root using sudo.

    So...

    $ sudo /etc/init.d/nscd restart

    For example (it will prompt the student to authenticate using
    their own password and cache it for a while).

    With regards to editing configuration files. This more
    difficult. Enabling an editor as root is as effective
    as giving full root priviledges. What you need is a way
    of copying configuration files of interest into each
    users home directory.... then you could write a simple
    script that a user could invoke via sudo that will take
    the user's version of the file and copy it into place.

    Consider the following script:

    # An example with two editable files... extend as you wish
    CONF_FILES="/etc/httpd/httpd.conf
    /etc/nsswitch.conf"

    while file in $CONF_FILES;do
            d=`date +%y%m%d%h%m%s`
            bname=`basename $file`
            dname=`dirname $file`
            userconf="~/UserConfs/$bname"
            if [ -f "$userconf" && ! cmp "$userconf" "$file" >/dev/null 2>&1 ]; then
                    echo "Updating $file with $userconf"
                    mv "$userconf" "$dname/$bname.$d"
                    cp "$userconf" "$file"
                     # Probably want to do something to capture
                     # and set permissions of the original file
                     # onto the replacement file....
            fi
    done

    Might be better to make CONF_FILES something passed in
    as an argument (only taking a single file)... but hopefully
    you will see the idea. The script above will always
    update any file that differs from the destination
    anytime it is run by the user (you would take the script
    and make it an allowable command via sudo).

    >
    > Thanks for any help,

    Hope that helps.
    Chris


  • Next message: pro: "where are logs if any change password?"

    Relevant Pages

    • Re: Card Reader
      ... Running your script ... instead of sudo is worthless because your script *can't do ... And of course it doesn't ask for a root password, ... >> That's just more bullshit Bryan, and you might as well leave ...
      (rec.photo.digital)
    • Re: pexpect with apache
      ... I added an entry for sudo for the script and it works without a hitch. ... could su to root from the command line, so I don't think that was it. ... using either sudo or the setuid flag would remove the need of ...
      (comp.lang.python)
    • Re: geli not working under non root user (Norberto Meijome)
      ... if I run under root user it work without problems. ... or is a problem of GELI? ... How can I give the operators sudo access to geli? ... script is very secure - you wouldn't want someone changing the contents of that ...
      (freebsd-questions)
    • Re: Card Reader
      ... Here's a simple Python script. ... Look Bryan, it makes no difference how many times you try this, ... sudo is *not* going to run your script. ... There is no actual root password; ...
      (rec.photo.digital)
    • RE: [Perl-beginners] Perl script to switch user to root.
      ... you obviously didn't read the sudo help pages, you can run the script as ... Onderwerp: Re: Perl script to switch user to root. ...
      (perl.beginners)