LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   sudoers config file crashed while editing and can no longer be written to (https://www.linuxquestions.org/questions/linux-software-2/sudoers-config-file-crashed-while-editing-and-can-no-longer-be-written-to-628328/)

CrinkElite 03-15-2008 07:09 PM

sudoers config file crashed while editing and can no longer be written to
 
Hi folks. I'm having a little trouble configuring the sudo command.
I'm running pendrive linux 2008. I installed it to a 1G usb from windows
here's the exact version
http://www.pendrivelinux.com/2008/02...dows/#more-342

I'm relatively new to linux.
the os does not come with sudo installed so i used the gui to locate and install the package. everything was going fine until i attempted to edit the file which controls the sudoers password settings and permissions using the CLI command

su --login -c 'visudo'

this loads a terminal edit session which contains a list of the sudo settings which can be edited and presumably saved.

while in this editing the page the edit session crashed so i loaded another terminal and re-entered the "su --login -c 'visudo'" command but instead of going straight to the settings file it gives this message




E325: ATTENTION
Found a swap file by the name "/etc/.sudoers.tmp.swp"
owned by: ******** dated: Sat Mar 15 08:32:34 2008
file name: /union/etc/sudoers.tmp
modified: YES
user name: ******** host name: 192.168.1.1
process ID: 9803
While opening file "/etc/sudoers.tmp"
dated: Tue Feb 27 14:41:40 2007

(1) Another program may be editing the same file.
If this is the case, be careful not to end up with two
different instances of the same file when making changes.
Quit, or continue with caution.

(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/sudoers.tmp"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.sudoers.tmp.swp"
to avoid this message.
"/etc/sudoers.tmp" 30L, 631C
Press ENTER or type command to continue


(for this post I've edited out the root login with *'s )


Then it displays the settings file but it will not save on exit.
it just reports that the sudoers file is unchanged.

When I try the :recover command I am presented with this



Swap files found:
Using specified name:
1. .sudoers.tmp.swn
owned by: ***** dated: Sat Mar 15 09:20:11 2008
file name: /union/etc/sudoers.tmp
modified: YES
user name: ****** host name: 192.168.1.1
process ID: 6656
2. .sudoers.tmp.swo
owned by: ****** dated: Sat Mar 15 08:57:16 2008
file name: /union/etc/sudoers.tmp
modified: YES
user name: ****** host name: 192.168.1.1
process ID: 6078
3. .sudoers.tmp.swp
owned by: ***** dated: Sat Mar 15 08:32:34 2008
file name: /union/etc/sudoers.tmp
modified: YES
user name: ****** host name: 192.168.1.1
process ID: 9803
In directory ~/tmp:
-- none --
In directory /var/tmp:
-- none --
In directory /tmp:
-- none --

Enter number of swap file to use (0 to quit):

#So I selected the oldest file -number 3


Enter number of swap file to use (0 to quit): 3
Using swap file "/union/etc/.sudoers.tmp.swp"
Original file "/union/etc/sudoers.tmp"
Recovery completed. You should check if everything is OK.
(You might want to write out this file under another name
and run diff with the original file to check for changes)
Delete the .swp file afterwards.


Press ENTER or type command to continue





using the teminal i have located these two files in the /union/etc/

sudoers
sudoers.tmp
suspend.conf

I'm not sure what the last part of the :recover output means by writing out the file under another name and running diff (sounds complicated)
my microsoft experiences tells me i should just rm all these sudoer files
and uninstall/reinstall the sudo package, however i dare not do this without a second opinion.

the other thing is that this distro is designed to be installed to a usb without the need to create a second partition for saving the changes in persistence mode. I *think* it saves changes to a special file located on the os partition. there is no active forum for this distro so I'm finding it hard to figure it out. I know that the swap file is located in system memory when the OS is running but i believe it must be saved to disk at shutdown because the shutdown funtions more like suspend ie. All programs that were open at the time of shutdown are restored faithfully on reboot . I don't know if that stuff is important or not but i said I'de better stick it in there just in case.

thanks a million for reading and sorry about the length, any info would be appreciated.

konsolebox 03-15-2008 10:23 PM

Quote:

Recovery completed. You should check if everything is OK.
(You might want to write out this file under another name
and run diff with the original file to check for changes)
Delete the .swp file afterwards.
these just means that you save the session to another file instead of the file you're trying to edit (original) then compare the original with the saved file.. just in case nothing's wrong with their difference, save the file to the original name.. for example if you saved it to a ifferent filename, like /union/etc/sudoers.tmp.new, do

Code:

diff -u /union/etc/sudoers.tmp{,.new}
then if there's not much difference,
do
Code:

mv /union/etc/sudoers.tmp{.new,}
which will replace the original

edit:
it's not really the new saved file that matters.. you should compare the swap file with the original instead:
Code:

diff -u /union/etc/sudoers.tmp{,.swp}

CrinkElite 03-16-2008 12:02 AM

thanks for the info konsolebox. It turns out that i wasn't using the right commands for the visudo editor and then I was getting the syntax wrong but thankfully i got it sorted, thanks for explaining the diff command, i didn't need it though I found a sample sudoers file
I was able to confirm that there are no errors in it
here's the sample

http://www.sudo.ws/sudo/sample.sudoers

thanks again


All times are GMT -5. The time now is 02:04 AM.