Bug 131323 - If smb.conf is deleted, program barfs on startup
Summary: If smb.conf is deleted, program barfs on startup
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-config-samba
Version: 2
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Nils Philippsen
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-08-30 23:58 UTC by Gianni Tedesco
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-10-09 23:33:21 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Gianni Tedesco 2004-08-30 23:58:47 UTC
in sambaParser.py the following code:

if os.access(path, os.W_OK) == 1:
            fd = open(path, 'w')
        else:
            dlg = gtk.MessageDialog(self.ParentClass.main_window, 0,
gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                    (_("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):
system-config-samba-1.2.9-2

How reproducible:
Always

Steps to Reproduce:
1. rm -f /etc/samba/smb.conf
2. system-config-samba
    

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.

Additional info:

Comment 1 Gianni Tedesco 2004-08-31 00:08:34 UTC
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.

Comment 2 Nils Philippsen 2004-09-15 13:22:38 UTC
I guess it should just install a sane default smb.conf if it is
missing, then work with that.

Comment 3 Gianni Tedesco 2004-09-17 09:30:16 UTC
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')

which does:

 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.

Comment 4 Gianni Tedesco 2004-09-17 09:35:10 UTC
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".

Comment 5 Nils Philippsen 2004-10-09 23:33:21 UTC
system-config-samba-1.2.20-1 (in Rawhide) should fix all three issues.

Next time please open separate bg reports, thanks.


Note You need to log in before you can comment on or make changes to this bug.