Bug 131323 - If smb.conf is deleted, program barfs on startup
If smb.conf is deleted, program barfs on startup
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: redhat-config-samba (Show other bugs)
2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Nils Philippsen
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-08-30 19:58 EDT by Gianni Tedesco
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-09 19:33:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Gianni Tedesco 2004-08-30 19:58:47 EDT
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-30 20:08:34 EDT
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 09:22:38 EDT
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 05:30:16 EDT
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 05:35:10 EDT
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 19:33:21 EDT
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.