chroot and getting the current user...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

chroot and getting the current user...

Richard Bucker
After reading the refs on submitting bug reports I believe this is the
correct way to present it as it's probably a design issue and may be
subjective as I know I do not know the whole system. So I will generalize
in the hopes that I'm wrong.

Everything starts with "my application"...
- chroot("some existing folder")
- mygetpwnam_r()  to get the current user which should be userid=0 or root.

when mygetpwnam_r runs it returns an error that the user could not be found.
I created an etc directory and put a passwd file in there with a record for
the root/0. But that returned the same error.

So I copied the /etc/pwd.db to my etc folder... and it worked.
One thing I thought... it might be useful to create an empty file but that
was not helpful. (pwd_mkdb)






*--Richard Bucker *
Reply | Threaded
Open this post in threaded view
|

Re: chroot and getting the current user...

Janne Johansson-3
Den tis 8 sep. 2020 kl 16:31 skrev Richard Bucker <[hidden email]>:

> After reading the refs on submitting bug reports I believe this is the
> correct way to present it as it's probably a design issue and may be
> subjective as I know I do not know the whole system. So I will generalize
> in the hopes that I'm wrong.
>
> Everything starts with "my application"...
> - chroot("some existing folder")
> - mygetpwnam_r()  to get the current user which should be userid=0 or root.
>
> when mygetpwnam_r runs it returns an error that the user could not be
> found.
> I created an etc directory and put a passwd file in there with a record for
> the root/0. But that returned the same error.
>
> So I copied the /etc/pwd.db to my etc folder... and it worked.
> One thing I thought... it might be useful to create an empty file but that
> was not helpful. (pwd_mkdb)
>

You should probably have run pwd_mkdb on a skeleton/minimal "master.passwd"
file, to
generate the *pwd.db files, and possibly with a -p to make a legacy
"passwd" in case
some program needs it.

--
May the most significant bit of your life be positive.
Reply | Threaded
Open this post in threaded view
|

Re: chroot and getting the current user...

Jeremie Courreges-Anglas-2
In reply to this post by Richard Bucker
On Tue, Sep 08 2020, Richard Bucker <[hidden email]> wrote:

> After reading the refs on submitting bug reports I believe this is the
> correct way to present it as it's probably a design issue and may be
> subjective as I know I do not know the whole system. So I will generalize
> in the hopes that I'm wrong.
>
> Everything starts with "my application"...
> - chroot("some existing folder")
> - mygetpwnam_r()  to get the current user which should be userid=0 or root.
>
> when mygetpwnam_r runs it returns an error that the user could not be
> found.

I don't understand why you expect this to work out of the box, for any
chroot directory under your control.  If you need to look up a passwd
entry you should probably do that before calling chroot(2).

This doesn't warrant a mail to bugs@ IMO.  Maybe ask misc@ next time if
you're unsure.

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply | Threaded
Open this post in threaded view
|

Re: chroot and getting the current user...

Richard Bucker
In reply to this post by Janne Johansson-3
@janne ... thanks. that was it. I did manage to get pwd_mkdb to work. As an
aside the help could use some improvement; but it did work!!

Thanks
*--Richard Bucker *




On Tue, Sep 8, 2020 at 10:45 AM Janne Johansson <[hidden email]> wrote:

> Den tis 8 sep. 2020 kl 16:31 skrev Richard Bucker <[hidden email]>:
>
>> After reading the refs on submitting bug reports I believe this is the
>> correct way to present it as it's probably a design issue and may be
>> subjective as I know I do not know the whole system. So I will generalize
>> in the hopes that I'm wrong.
>>
>> Everything starts with "my application"...
>> - chroot("some existing folder")
>> - mygetpwnam_r()  to get the current user which should be userid=0 or
>> root.
>>
>> when mygetpwnam_r runs it returns an error that the user could not be
>> found.
>> I created an etc directory and put a passwd file in there with a record
>> for
>> the root/0. But that returned the same error.
>>
>> So I copied the /etc/pwd.db to my etc folder... and it worked.
>> One thing I thought... it might be useful to create an empty file but that
>> was not helpful. (pwd_mkdb)
>>
>
> You should probably have run pwd_mkdb on a skeleton/minimal
> "master.passwd" file, to
> generate the *pwd.db files, and possibly with a -p to make a legacy
> "passwd" in case
> some program needs it.
>
> --
> May the most significant bit of your life be positive.
>