Skip to main content
added 1511 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

sudoers file

You should be able to do this, I think you're encountering a quoting/spacing issue in your definitionany of the command sudoedit /path/to/filethese.

  1. Such as this:

     john ALL=(ALL) NOPASSWD: sudoedit
    
  2. or this:

     john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
    
  3. Lastly you could do it like this too:

     Cmnd_Alias SOMECMD = sudoedit /path/to/file
     john ALL=(ALL) NOPASSWD: SOMECMD
    

For starters I'd try just thisOnce you have one of these definitions in place you invoke it like so:

john ALL=(ALL) NOPASSWD:sudoedit /usrpath/binto/sudoeditfile

Details

If this works then I'd tryYou don't need to invoke it with a sudo command prefix like this:

Cmnd_Alias SOMECMD =sudo /usr/bin/sudoedit /pathpat/to/file
john

It takes care of the sudo automatically. It's equivalent to sudo -e /pat/to/file which will invoke an editor with elevated privileges.

excerpt from the sudo/sudoedit man page

-e ALL=         The -e (ALLedit) NOPASSWDoption indicates that, instead of running a command, 
            the user wishes to edit one or more files. In lieu of a command, the 
            string "sudoedit" is used when consulting the sudoers file.  If the 
            user is authorized by sudoers the following steps are taken: 

 SOMECMD              1.  Temporary copies are made of the files to be edited with the 
                   owner set to the invoking user.

               2.  The editor specified by the SUDO_EDITOR, VISUAL or EDITOR 
                   environment variables is run to edit the temporary files.  
                   If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first 
                   program listed in the editor sudoers variable is used.

               3.  If they have been modified, the temporary files are copied 
                   back to their original location and the temporary versions 
                   are removed.

You can override the editor by setting one of the environment variables mentioned above with the name of an editor to use such as vim or gedit, for example.

You should be able to do this, I think you're encountering a quoting/spacing issue in your definition of the command sudoedit /path/to/file.

For starters I'd try just this:

john ALL=(ALL) NOPASSWD: /usr/bin/sudoedit

If this works then I'd try to this:

Cmnd_Alias SOMECMD = /usr/bin/sudoedit /path/to/file
john ALL=(ALL) NOPASSWD: SOMECMD

sudoers file

You should be able to do any of these.

  1. Such as this:

     john ALL=(ALL) NOPASSWD: sudoedit
    
  2. or this:

     john ALL=(ALL) NOPASSWD: sudoedit /path/to/file
    
  3. Lastly you could do it like this too:

     Cmnd_Alias SOMECMD = sudoedit /path/to/file
     john ALL=(ALL) NOPASSWD: SOMECMD
    

Once you have one of these definitions in place you invoke it like so:

sudoedit /path/to/file

Details

You don't need to invoke it with a sudo command prefix like this:

sudo sudoedit /pat/to/file

It takes care of the sudo automatically. It's equivalent to sudo -e /pat/to/file which will invoke an editor with elevated privileges.

excerpt from the sudo/sudoedit man page

-e          The -e (edit) option indicates that, instead of running a command, 
            the user wishes to edit one or more files. In lieu of a command, the 
            string "sudoedit" is used when consulting the sudoers file.  If the 
            user is authorized by sudoers the following steps are taken: 

               1.  Temporary copies are made of the files to be edited with the 
                   owner set to the invoking user.

               2.  The editor specified by the SUDO_EDITOR, VISUAL or EDITOR 
                   environment variables is run to edit the temporary files.  
                   If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first 
                   program listed in the editor sudoers variable is used.

               3.  If they have been modified, the temporary files are copied 
                   back to their original location and the temporary versions 
                   are removed.

You can override the editor by setting one of the environment variables mentioned above with the name of an editor to use such as vim or gedit, for example.

added 30 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

You should be able to do this, I think you're encountering a quoting/spacing issue in your definition of the command sudoedit /path/to/file.

For starters I'd try just this:

john ALL=(ALL) NOPASSWD: /usr/bin/sudoedit

If this works then I'd try to this:

johnCmnd_Alias ALL=(ALL)SOMECMD NOPASSWD:= "/usr/bin/sudoedit /path/to/file"file
john ALL=(ALL) NOPASSWD: SOMECMD

You should be able to do this, I think you're encountering a quoting/spacing issue in your definition of the command sudoedit /path/to/file.

For starters I'd try just this:

john ALL=(ALL) NOPASSWD: /usr/bin/sudoedit

If this works then I'd try to this:

john ALL=(ALL) NOPASSWD: "/usr/bin/sudoedit /path/to/file"

You should be able to do this, I think you're encountering a quoting/spacing issue in your definition of the command sudoedit /path/to/file.

For starters I'd try just this:

john ALL=(ALL) NOPASSWD: /usr/bin/sudoedit

If this works then I'd try to this:

Cmnd_Alias SOMECMD = /usr/bin/sudoedit /path/to/file
john ALL=(ALL) NOPASSWD: SOMECMD
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

You should be able to do this, I think you're encountering a quoting/spacing issue in your definition of the command sudoedit /path/to/file.

For starters I'd try just this:

john ALL=(ALL) NOPASSWD: /usr/bin/sudoedit

If this works then I'd try to this:

john ALL=(ALL) NOPASSWD: "/usr/bin/sudoedit /path/to/file"