info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mtools] Patches from NetBSD pkgsrc


From: Alain Knaff
Subject: Re: [Mtools] Patches from NetBSD pkgsrc
Date: Sun, 15 Feb 2009 17:09:23 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Sergey Svishchev wrote:
> Good day,
> 
> I am forwarding assorted patches that are included into mtools package 
> in NetBSD (and other operating systems that use pkgsrc framework).  They 
> apply cleanly to 3.9.10.

Some of these are now in mtools 4.0.4

> 
> Enhance "floppyd" to get UID of "nobody" from the password database.
> --- floppyd.c.orig    2002-11-02 10:55:24.000000000 +0000
> +++ floppyd.c
> @@ -583,7 +583,7 @@ static uid_t getuserid(char *user)
>               }
>       else
>               {
> -                     uid = 65535;
> +                     uid = getuserid("nobody");
>               }
> 
>   #if DEBUG
> @@ -609,7 +609,7 @@ static uid_t getgroupid(uid_t uid)
>               }
>       else
>               {
> -                     gid = 65535;
> +                     gid = getgroupid(uid);
>               }
> 
>   #if DEBUG

I put this in, after bracketing it with #ifdef HAVE_GETUSERID
Indeed, the getuserid does not exist on many other platforms, and it's
still important not to break compilation on these :-)

> Autoconfiguration process defines OS_netbsdelf on all current NetBSD 
> platforms (NetBSD PR 21530).
> --- devices.c.orig    2003-05-24 20:54:27.000000000 +0000
> +++ devices.c
> @@ -807,7 +807,7 @@ struct device devices[] = {
>   #endif /* __FreeBSD__ */
> 
>   /*** /jes -- for ALR 486 DX4/100 ***/
> -#if defined(OS_netbsd)
> +#if defined(OS_netbsd) || defined(OS_netbsdelf)
>   #define predefined_devices
>   struct device devices[] = {
>       {"/dev/rfd0a", 'A', FHD312},

This is now in as well.

> 
> Set effective gid so that privileges can be regained later (NetBSD PR 18771)
> --- privileges.c.orig 2003-12-11 18:07:44.000000000 +0000
> +++ privileges.c
> @@ -68,7 +68,7 @@ void reclaim_privs(void)
>   {
>       if(noPrivileges)
>               return;
> -     setgid(egid);
> +     setegid(egid);
>       Setuid(euid);
>       print_privs("after reclaim privs, both uids should be 0 ");
>   }
> @@ -76,7 +76,7 @@ void reclaim_privs(void)
>   void drop_privs(void)
>   {
>       Setuid(ruid);
> -     setgid(rgid);
> +     setegid(rgid);
>       print_privs("after drop_privs, real should be 0, effective should not 
> ");
>   }

This one is not in. Indeed, I had some problem seeing the purpose. The
only difference (as far as I could tell...) between setgid and setegid
is that setgid loses the original real group id and saved group id if
the user id happened to be root, making it impossible to "go back".
However, due to the ordering of the Setuid calls and setgid calls, this
situation actually only occurs if both real and effective uid are zero,
which makes it possible to go back, as in that case the program is fully
privileged.

However, setgid is more universal than setegid, so I left it as is.

Unless there is some other reason for this?

> 
> 
> Use thread-safe errno definition provided in system headers.

Equivalent changes as below are already in in the meantime. (sorry for
my slow reply, had misplaced some of my mtools mails in a folder which I
rarely visited)

> Fix problem with sector sizes > 1024 bytes.
> --- init.c.orig       2002-05-01 09:57:02.000000000 +0000
> +++ init.c
> @@ -14,9 +14,6 @@
>   #include "xdf_io.h"
>   #include "buffer.h"
> 
> -extern int errno;
> -
> -
[...]

Regards.

Alain


reply via email to

[Prev in Thread] Current Thread [Next in Thread]