Linux MS DOS discussions
 help / color / mirror / Atom feed
* root can't access files?
@ 2003-08-03  2:50 Ryan Underwood
  2003-08-03  3:01 ` Ryan Underwood
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Underwood @ 2003-08-03  2:50 UTC (permalink / raw)
  To: linux-msdos


Hi,

I have some file that is mode 600, owned by user.user.  If root tries to
access that file from within dosemu, he gets "access denied".  How can
it be specified, that root running dosemu means he gets to do anything
within DOS?

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-03  2:50 root can't access files? Ryan Underwood
@ 2003-08-03  3:01 ` Ryan Underwood
  2003-08-04  2:00   ` Ryan Underwood
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Underwood @ 2003-08-03  3:01 UTC (permalink / raw)
  To: linux-msdos


I found that the behavior is different when using sudo than when root
has a login shell (or su).  The sudo won't allow access.  Strange!


On Sat, Aug 02, 2003 at 09:50:37PM -0500, Ryan Underwood wrote:
> 
> Hi,
> 
> I have some file that is mode 600, owned by user.user.  If root tries to
> access that file from within dosemu, he gets "access denied".  How can
> it be specified, that root running dosemu means he gets to do anything
> within DOS?
> 
> -- 
> Ryan Underwood, <nemesis at icequake.net>, icq=10317253
> -
> To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-03  3:01 ` Ryan Underwood
@ 2003-08-04  2:00   ` Ryan Underwood
       [not found]     ` <20030804164736.28318.qmail@web14301.mail.yahoo.com>
  2003-08-04 22:40     ` Bart Oldeman
  0 siblings, 2 replies; 8+ messages in thread
From: Ryan Underwood @ 2003-08-04  2:00 UTC (permalink / raw)
  To: linux-msdos


Okay, I figured out what is going on.

I have a daemon (BBS server) that is spawned from an init script, and
when a user accesses a DOS program in the BBS, it forks off DOSEMU to
redirect the comport I/O to the user.

The problem occurs when:
1) The daemon is run with root privileges
2) The daemon's init script is run through a `sudo`.

The latter is common since the sysop might use sudo to either restart
the BBS, or to apt-get upgrade (which will restart the daemon as part of
its process).  DOSEMU checks to the "real" uid, drops privileges to the
real uid, and then can no longer access the files which have root
permissions.  So it fails starting the user's requested program for
seemingly no reason.  However, when done a `su - root` and then running
the init script, there is no problem, since the real login is root that
time.

I explored various stupid hacks in the privilege code, but I just
thought I would ask if anyone has a better idea how to use sudo with
dosemu.  This is a little bit of a pain!

Ryan

On Sat, Aug 02, 2003 at 10:01:27PM -0500, Ryan Underwood wrote:
> 
> I found that the behavior is different when using sudo than when root
> has a login shell (or su).  The sudo won't allow access.  Strange!
> 
> 
> On Sat, Aug 02, 2003 at 09:50:37PM -0500, Ryan Underwood wrote:
> > 
> > Hi,
> > 
> > I have some file that is mode 600, owned by user.user.  If root tries to
> > access that file from within dosemu, he gets "access denied".  How can
> > it be specified, that root running dosemu means he gets to do anything
> > within DOS?
> > 
> > -- 
> > Ryan Underwood, <nemesis at icequake.net>, icq=10317253
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> 
> -- 
> Ryan Underwood, <nemesis at icequake.net>, icq=10317253
> -
> To unsubscribe from this list: send the line "unsubscribe linux-msdos" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
       [not found]     ` <20030804164736.28318.qmail@web14301.mail.yahoo.com>
@ 2003-08-04 19:11       ` Ryan Underwood
  0 siblings, 0 replies; 8+ messages in thread
From: Ryan Underwood @ 2003-08-04 19:11 UTC (permalink / raw)
  To: linux-msdos


Hi,

On Mon, Aug 04, 2003 at 09:47:36AM -0700, ToniB wrote:
> --- Ryan Underwood <nemesis-lists@icequake.net> wrote:
>  
> > The problem occurs when:
> > 1) The daemon is run with root privileges
> > 2) The daemon's init script is run through a `sudo`.
> > 
> > DOSEMU checks to the "real" uid, drops privileges to the
> > real uid, and then can no longer access the files which have root
> > permissions.  So it fails starting the user's requested program for
> > 
> 
> 'man sudoers' explains how you can add a line
> to allow users to exec a file or  cmd line.
> 
> You might  want to give access to all users,
> to the command (that ony root can exec now),
> by adding a line like
> 
> USERS-LIST BBS-HOST=cmdline
> 
> to your sudoers file.

Thanks for the reply.  I'm still having trouble seeing how that would
affect the issue.  The problem is not that people are not able to run
sudo; it is that when sudo is used to run the init script, when dosemu
eventually becomes a child process of (a child process of) the init
script, it sees that "hm, this program is running as root, but the real
uid of the person who started it is not root", and drops the root
privileges that were afforded to it by sudo.  When a "real" root login
runs the init script, then dosemu sees that the real uid matches the
effective uid, and doesn't drop privileges.

Do you see what I mean?

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-04  2:00   ` Ryan Underwood
       [not found]     ` <20030804164736.28318.qmail@web14301.mail.yahoo.com>
@ 2003-08-04 22:40     ` Bart Oldeman
  2003-08-29  4:39       ` Ryan Underwood
  1 sibling, 1 reply; 8+ messages in thread
From: Bart Oldeman @ 2003-08-04 22:40 UTC (permalink / raw)
  To: linux-msdos

On Sun, 3 Aug 2003, Ryan Underwood wrote:

> Okay, I figured out what is going on.
>
> I have a daemon (BBS server) that is spawned from an init script, and
> when a user accesses a DOS program in the BBS, it forks off DOSEMU to
> redirect the comport I/O to the user.
>
> The problem occurs when:
> 1) The daemon is run with root privileges
> 2) The daemon's init script is run through a `sudo`.
>
> The latter is common since the sysop might use sudo to either restart
> the BBS, or to apt-get upgrade (which will restart the daemon as part of
> its process).  DOSEMU checks to the "real" uid, drops privileges to the
> real uid, and then can no longer access the files which have root
> permissions.

This is a way to avoid suid-root on dosemu.bin and let sudo manage much of
the security that used to be done by dosemu.users settings. Sudo is much
more reliable than DOSEMU security wise (better audits and so on).

Look at the file named "INSTALL" for a possible setup.

> So it fails starting the user's requested program for
> seemingly no reason.  However, when done a `su - root` and then running
> the init script, there is no problem, since the real login is root that
> time.
>
> I explored various stupid hacks in the privilege code, but I just
> thought I would ask if anyone has a better idea how to use sudo with
> dosemu.  This is a little bit of a pain!

using it twice, like
sudo sudo dosemu
should work around it. The script user then needs to be able to gain
absolute (unlimited) root using sudo however (i.e. able to run "sudo
bash"), and not just the permission to execute dosemu.bin with "root".

Bart


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-04 22:40     ` Bart Oldeman
@ 2003-08-29  4:39       ` Ryan Underwood
  2003-08-29  9:37         ` Bart Oldeman
  0 siblings, 1 reply; 8+ messages in thread
From: Ryan Underwood @ 2003-08-29  4:39 UTC (permalink / raw)
  To: linux-msdos


Bart,

On Mon, Aug 04, 2003 at 11:40:12PM +0100, Bart Oldeman wrote:
> On Sun, 3 Aug 2003, Ryan Underwood wrote:
> 
> > Okay, I figured out what is going on.
> >
> > I have a daemon (BBS server) that is spawned from an init script, and
> > when a user accesses a DOS program in the BBS, it forks off DOSEMU to
> > redirect the comport I/O to the user.
> >
> > The problem occurs when:
> > 1) The daemon is run with root privileges
> > 2) The daemon's init script is run through a `sudo`.
> >
> > The latter is common since the sysop might use sudo to either restart
> > the BBS, or to apt-get upgrade (which will restart the daemon as part of
> > its process).  DOSEMU checks to the "real" uid, drops privileges to the
> > real uid, and then can no longer access the files which have root
> > permissions.
> 
> This is a way to avoid suid-root on dosemu.bin and let sudo manage much of
> the security that used to be done by dosemu.users settings. Sudo is much
> more reliable than DOSEMU security wise (better audits and so on).
> 
> Look at the file named "INSTALL" for a possible setup.
> 
> > So it fails starting the user's requested program for
> > seemingly no reason.  However, when done a `su - root` and then running
> > the init script, there is no problem, since the real login is root that
> > time.
> >
> > I explored various stupid hacks in the privilege code, but I just
> > thought I would ask if anyone has a better idea how to use sudo with
> > dosemu.  This is a little bit of a pain!
> 
> using it twice, like
> sudo sudo dosemu
> should work around it. The script user then needs to be able to gain
> absolute (unlimited) root using sudo however (i.e. able to run "sudo
> bash"), and not just the permission to execute dosemu.bin with "root".

I found another mis-behavior of this feature, involving the opposite
scenario.

Before, we were a regular user, using sudo to start the bbs,
and the dosemu ended up inappropriately dropping its privileges because
it was started setuid root.

Now, the other scenario is this:  we are root, and startup the bbs as
root.  The BBS this time is configured to setuid to another user for the
security reasons, so it setuids to 'bbs'.  dosemu is started as 'bbs',
but apparently checks the real uid to find where to access ~/.dosemu,
tries to write to files in /root/.dosemu which 'bbs' has no permissions
for, and quits immediately when it fails.

Any thoughts?  I'm thinking it might be useful to have a setting in
dosemu.users that turns off the "smart setuid handling", because
sometimes it is not desired.

Also, is it possible to create the stuff that dosemu would want to
create in .dosemu, somewhere else such as /tmp that the user will always
be able to write to; or else disable creating the sockets and such
entirely?  That way, dosemu would not need write permissions anywhere to
start up.

Your thoughts welcome,

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-29  4:39       ` Ryan Underwood
@ 2003-08-29  9:37         ` Bart Oldeman
  2003-08-29 19:01           ` Ryan Underwood
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Oldeman @ 2003-08-29  9:37 UTC (permalink / raw)
  To: Ryan Underwood; +Cc: linux-msdos

On Thu, 28 Aug 2003, Ryan Underwood wrote:

> Now, the other scenario is this:  we are root, and startup the bbs as
> root.  The BBS this time is configured to setuid to another user for the
> security reasons, so it setuids to 'bbs'.  dosemu is started as 'bbs',
> but apparently checks the real uid to find where to access ~/.dosemu,
> tries to write to files in /root/.dosemu which 'bbs' has no permissions
> for, and quits immediately when it fails.

No, as far as I can't see simply uses $HOME/.dosemu. I can't see any
extraction of the home directory name from /etc/passwd.

The easiest way to workaround would be to start using HOME=/home/bbs

> Also, is it possible to create the stuff that dosemu would want to
> create in .dosemu, somewhere else such as /tmp that the user will always
> be able to write to; or else disable creating the sockets and such
> entirely?  That way, dosemu would not need write permissions anywhere to
> start up.

With a little experimenting it turns out that read access is enough
without any changes to the source code.
HOME=/root dosemu.bin -o /dev/null
works as long as the user who invokes it can see /root/.dosemu
HOME=/tmp dosemu
works too.

I'm not sure if that's sufficient for you but at least it's something.

Bart


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: root can't access files?
  2003-08-29  9:37         ` Bart Oldeman
@ 2003-08-29 19:01           ` Ryan Underwood
  0 siblings, 0 replies; 8+ messages in thread
From: Ryan Underwood @ 2003-08-29 19:01 UTC (permalink / raw)
  To: linux-msdos


Hi Bart,

On Fri, Aug 29, 2003 at 10:37:27AM +0100, Bart Oldeman wrote:
> On Thu, 28 Aug 2003, Ryan Underwood wrote:
> 
> > Now, the other scenario is this:  we are root, and startup the bbs as
> > root.  The BBS this time is configured to setuid to another user for the
> > security reasons, so it setuids to 'bbs'.  dosemu is started as 'bbs',
> > but apparently checks the real uid to find where to access ~/.dosemu,
> > tries to write to files in /root/.dosemu which 'bbs' has no permissions
> > for, and quits immediately when it fails.
> 
> No, as far as I can't see simply uses $HOME/.dosemu. I can't see any
> extraction of the home directory name from /etc/passwd.
> 
> The easiest way to workaround would be to start using HOME=/home/bbs

Of course, I was up late and the obvious solution completely escaped me.
For some reason I was thinking the DOSEMU was getting the home directory
from the pwent instead of the environment $HOME.  Silly! :)

-- 
Ryan Underwood, <nemesis at icequake.net>, icq=10317253

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-08-29 19:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-03  2:50 root can't access files? Ryan Underwood
2003-08-03  3:01 ` Ryan Underwood
2003-08-04  2:00   ` Ryan Underwood
     [not found]     ` <20030804164736.28318.qmail@web14301.mail.yahoo.com>
2003-08-04 19:11       ` Ryan Underwood
2003-08-04 22:40     ` Bart Oldeman
2003-08-29  4:39       ` Ryan Underwood
2003-08-29  9:37         ` Bart Oldeman
2003-08-29 19:01           ` Ryan Underwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox