The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Edit 'hosts' by non-administrators (http://hintsforums.macworld.com/showthread.php?t=99568)

trevor 08-31-2009 11:48 PM

honestpuck, 10.5.x /usr/bin/sudo honors the -e flag, but in testing it seems to always try to force the file to be in /var/tmp (no matter what path you gave the filename) and appends a 6 character, seemingly random file extension on the end of the filename. It's not particularly clear to me what it is trying to do.

Quote:

Originally Posted by man sudo
Code:

      -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 VISUAL or EDITOR environment
                  variables is run to edit the temporary files.  If neither
                  VISUAL nor EDITOR are set, the 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.

          If the specified file does not exist, it will be created.  Note
          that unlike most commands run by sudo, the editor is run with the
          invoking user's environment unmodified.  If, for some reason, sudo
          is unable to update a file with its edited version, the user will
          receive a warning and the edited copy will remain in a temporary
          file.


Trevor

honestpuck 09-01-2009 01:24 AM

Yeah, that's the behaviour I saw. On a Linux VM I have it works great but on 10.5 it's broke. I guess I could have been a little more explicit, it does try and do something but does it broken.

On my testing I also saw that sudo seems to much prefer the "%" flag than the "+" flag and also wants the path to the command to be explicit as well so the line should have '/usr/bin/rvim'.

Suffice to say that some experimentation with the exact syntax is probably required - my testing was complicated by the fact that both the accounts I use on both my Macs are already listed in sudoers.

// Tony


All times are GMT -5. The time now is 05:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.