Red Hat Bugzilla – Bug 131323
If smb.conf is deleted, program barfs on startup
Last modified: 2007-11-30 17:10:48 EST
in sambaParser.py the following code:
if os.access(path, os.W_OK) == 1:
fd = open(path, 'w')
dlg = gtk.MessageDialog(self.ParentClass.main_window, 0,
(_("Cannot write to %s. Program
will now exit." % path)))
means that if the config file doesn't exist, the tool cannot be
started. This is a textbook case of where access() should not be used.
The exception thrown by os.open() needs catching and more descriptive
error message given based on this. The same bug exists in other places
too, but this is the one I happened to hit.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. rm -f /etc/samba/smb.conf
Actual Results: Uninformative error dialog "Cannot write to
/etc/samba/smb.conf. Program will now exit."
Expected Results: system-config-samba ought to have started normally.
Ah, now I see it's the case that the tool also won't create a working
smb.conf if it has been deleted anyway, so this is a mode of operation
that is not supported I guess.
I guess it should just install a sane default smb.conf if it is
missing, then work with that.
Yeah, that'd be a ideal. All the tools should probably do likewise.
Certainly they need to give the user a way out of a problem that is
all too likely to occur.
In fact it is possible for the tool to destroy or corrupt the smb.conf
itself, look at line 196 in writeFile:
fd = open(path, 'w')
open("/etc/samba/smb.conf", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666);
We've truncated the old config without making sure that the new data
is safe on the disk. If the system crashes, the disk fills, the power
is cut or another process started writing here, then we have lost or
corrupted the data.
Ah, not to mention that the default mode needs fixing to prevent local
root exploits if root (stupidly) decides to run without umask of 022 ;)
At least system-config-network sets umask explicitly "Just to be safe".
system-config-samba-1.2.20-1 (in Rawhide) should fix all three issues.
Next time please open separate bg reports, thanks.