delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2020/07/24/09:33:05

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20161025;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=ohcrov/H8AbVxQbFlO4VKrN52qoTg1jZMSkplc0KQ6A=;
b=JZMcDQ/quVk8zvK9CUPttV4R07exDOwFVQtIP0BEqLdg9i498aHFuXhtxxiVZxKU0+
RWNuZASJZPk4TBbmVUub5H4GZJqOFLvpw926qE69kiuiE3gZwah+nVqn4WSN8myVOuJA
AatPh+WNabD0OqJH+dmyPdMPKd8HPupJ7aLjXXgGGKt4kRG0Twty4C246F87zL94UWKL
k/sHmaelbZXAn7XJRZ6mNuAub6jjBvbDR6i7C+S0Y8059nnXofO6ky2KjQnEOHv8Fw+v
JYN2JbaNAc+SZENN4WB35JNxHmLYayQCM4VAsTYxgGlTC/8qP+QQMeVl3lfKiNVkiRJL
FHSA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=ohcrov/H8AbVxQbFlO4VKrN52qoTg1jZMSkplc0KQ6A=;
b=TDDlFX50Ut6Oqj5hIQsnRRMjAAW15E0DISPFSRIxjzMFV8VJWSLJj+tbLDvj6dPefI
CfNTcpXTpn86Jr5S7MhogsIdM5Ri6/vAQ2X6QY2xfnKDjq5n4Wgeiw8KQaIQ1LT3e10R
vAfwtSPwAy8csZwFH0Hn/KXagzXz7fqKMxxjfM5oqsCIJVnqjHLM9oawd0+Hz5lTww16
jaA5mq4VH+AhLyfdqin5mYXvMKlWHWpsdCHKIiNl6BoPkI6zu3nEClSyCzYneBfC5Iq7
63uH/pBMjf5iuWNcs5ERlmbDcUjNNOv6xyUXGkF5vErSB/ilXSGbNfQhPyBBZDvVQ4yM
z+Jg==
X-Gm-Message-State: AOAM530uU1snaCjFJj5bR+hl3wnwguipQBUGb+mRDh2eaerhExFg6sAq
RXvoTZDMGh+lY9gaN0Ckdw2V5eBPRjnyw51B92k+lJy0
X-Google-Smtp-Source: ABdhPJzA9g4BDKBmWtLkHbqDeNtJ35q7N7K4dh79Y+bYmhd8qIP+zY/Ukyu1hUFfZDBG7800oOWxzMWk+lOa3J6OzNM=
X-Received: by 2002:a2e:99c6:: with SMTP id l6mr4762337ljj.220.1595597328366;
Fri, 24 Jul 2020 06:28:48 -0700 (PDT)
MIME-Version: 1.0
References: <CALPW7mQEoAS0V+Jfvnc9hsYdSXWctJ3FFnLYfNqiqSw=dQ5fPw AT mail DOT gmail DOT com>
<5F19DFF6 DOT 3020009 AT gmx DOT de>
In-Reply-To: <5F19DFF6.3020009@gmx.de>
From: "A. Wik (awik32 AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
Date: Fri, 24 Jul 2020 13:28:36 +0000
Message-ID: <CALPW7mS5nMXUwsyU2mhi-AXkhG4VCrqUB5bqgN9=p-RLabbjtw@mail.gmail.com>
Subject: Re: User id
To: djgpp AT delorie DOT com
Reply-To: djgpp AT delorie DOT com

Hi,

and thanks for your elaborate reply.

On Thu, 23 Jul 2020 at 19:15, Juan Manuel Guerrero
(juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com] <djgpp AT delorie DOT com>
wrote:
>
> Am 21.07.2020 21:25, schrieb A. Wik (awik32 AT gmail DOT com) [via djgpp AT delorie DOT com]:
> > Hi all,
> >
> > How do I convince BASH that I'm root and that my UID is 0 and not 42?
> >
> > I've tried editing the "djgpp.env" file.
> >
> > I also tried installing an "etc/passwd" file under the djgpp
> > directory, with "dosuser" listed as having uid 0.
> >
> > Regards,
> > Albert.
>
> There is no way to do what you want to do.
> MSDOS does not know anything about uid and similars

Of course, I think we all know that.

> thus neither the port nor
> the c library supports them in the way it is known from unix.  All versions
> of this port have relayed on the getuid and setuid functions provided by the
> library.  Because there is nothing like uid and alike on MSDOS these functions
> emulate them for porting purposes with hard coded values.  In the case of uid/gid
> the value is 42 when read by getuid and expects an uid of 42 when set by setuid;
> any different value will make setuid fail with EPERM.

I understand.

> Currently I have no intentions to update the bash port providing such an uid/gid
> emulation.  I even would not really know how to implement it in a way that it
> becomes a serious emulation of the unix functionality completely missed on MSDOS.

It doesn't need to be "serious".  It does, in my mind, have to be configurable.

> If you are completely despaired to have a root uid behaviour, you will have
> to modify the code of the [g|s]etui() functions of the library in such a way
> that they read a defined environment variable that defines the current uid/gid
> to be used.

Right.  Using the environment variables sounds like a reasonable solution.

> With this modified libc.a you can then recompile the bash port and
> see what happens.  But it is clear that no other program than the recompiled
> bash port will know about this modified g|s]etui().  In the worst case you
> would have to recompile also the shell utilities and file utilities and some
> other ports more.  And if they really behave as root user mode on plain DOS
> needs to be investigated.
> If all this is worth to be done must be decided by you.  I am also not really
> convinced that this will work at all.

I used a shortcut solution.  I have a utility program called HIEW.EXE,
which can display a file in hex, ASCII, and 16/32-bit assembly
language, and also edit them.

First, I did this:
C:\djgpp\lib\x>ar -xov ../libc.a getuid.o
x - getuid.o

Examining getuid.o, I found out that the relevant machine code is
0xB8,2A,00,00,00 for "mov eax, 42".  I patched BASH, the C-library
(libc.a), and the "id.exe" utility, replacing 0x2A with 00.  I also
replaced "dosuser\0" with "root\0er\0".  I left the group name as
"dos" for obvious reasons.

Result:
C:\djgpp\lib\x>bash
bash-2.04# id
uid=0(root) gid=0(dos)
bash-2.04#

But in the longer term, this should be fixed in the C library.  I
guess it is easy enough that I could even do it myself.  We'll see.

Cheers,
Albert.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019