Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2018-01

Get user ID for name on Linux

11 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tobias Giesen

Hello,

I would like to get the user ID for a Linux user name.

Unfortunately Libc and UnixUtils don't seem to be available in 64-bit, so I can't call the functions getpwnam or GetUserId. Is there a replacement? Or could I define and import the function myself?

Thanks for any help!

Cheers,
Tobias

Reply by email

Marco van de Voort
to Tobias Giesen

In our previous episode, Tobias Giesen said:

Show quoted text 5 lines
I would like to get the user ID for a Linux user name. Unfortunately Libc and UnixUtils don't seem to be available in 64-bit, so I can't call the functions getpwnam or GetUserId. Is there a replacement? Or could I define and import the function myself?

Try the units in package users (packages/users in the sources)

Reply by email

Graeme Geldenhuys
to Tobias Giesen: I would like to get the user ID for a Linux user name. Unfortunately Libc and UnixUtils…
Tobias Giesen wrote
Unfortunately Libc and UnixUtils don't seem to be available in 64-bit, so I can't call the functions getpwnam or GetUserId.

As Marco said, you can use the "users" unit. Here is an example of how I use in in fpGUI, and it supports 32-bit and 64-bit systems.

https://github.com/graemeg/fpGUI/blob/develop/src/corelib/x11/fpg_x11.pas#L4010-L4044

Note though that it only works for Linux. So other UNIX-type systems like FreeBSD and Solaris are not supported.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Tobias Giesen
to Graeme Geldenhuys: As Marco said, you can use the "users" unit. Here is an example of how I use in in fpGUI,…

Many thanks! That's great. The completeness of FPC units and packages is really astonishing.

Cheers,
Tobias

----

Show quoted text 25 lines
On 2018-01-03 00:12, Tobias Giesen wrote: > Unfortunately Libc and UnixUtils don't seem to be available in 64-bit, so I can't call the > functions getpwnam or GetUserId. As Marco said, you can use the "users" unit. Here is an example of how I use in in fpGUI, and it supports 32-bit and 64-bit systems. https://github.com/graemeg/fpGUI/blob/develop/src/corelib/x11/fpg_x11.pas#L4010-L4044 Note though that it only works for Linux. So other UNIX-type systems like FreeBSD and Solaris are not supported. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Kind Regards,
Tobias Giesen

Super Flexible Software Ltd. & Co. KG
Buddenstr. 29-31
48143 Münster, Germany
www.superflexible.com
www.tgtools.com

----------------------------------------------------------- Registered at register court Münster as HRA 9716
Liability / general partner: TGTools Ltd.
Company No. 05513299
Registered in England and Wales
Directors: Tobias Giesen and Claudia Giesen

Reply by email

geneb
to Tobias Giesen
Tobias Giesen wrote
Many thanks! That's great. The completeness of FPC units and packages is really astonishing.

Is there a complete list of packages available somewhere?

tnx.

g.

Proud owner of F-15C 80-0007 http://www.f15sim.com - The only one of its kind. http://www.diy-cockpits.org/coll - Go Collimated or Go Home. Some people collect things for a hobby. Geeks collect hobbies. ScarletDME - The red hot Data Management Environment A Multi-Value database for the masses, not the classes. http://scarlet.deltasoft.com - Get it _today_!

Reply by email

Marco van de Voort
to geneb

In our previous episode, geneb said:

Show quoted text 5 lines
> Many thanks! That's great. The completeness of FPC units and packages is really > astonishing. > Is there a complete list of packages available somewhere?

There is some info(1) in the wiki, though many details are missing, and the status of each package is not explicitely recorded.

There however is a page specific about the libc_unit (2) that named the "users" package as a replacement for certain calls.

(1) http://wiki.freepascal.org/Package_List
(2) http://wiki.freepascal.org/libc_unit

Reply by email

geneb
to Marco van de Voort
Marco van de Voort wrote 13 lines
In our previous episode, geneb said: > > > Many thanks! That's great. The completeness of FPC units and packages is really > > astonishing. > > > Is there a complete list of packages available somewhere? There is some info(1) in the wiki, though many details are missing, and the status of each package is not explicitely recorded. There however is a page specific about the libc_unit (2) that named the "users" package as a replacement for certain calls.

Thanks for the info Marco.
g
.

Proud owner of F-15C 80-0007 http://www.f15sim.com - The only one of its kind. http://www.diy-cockpits.org/coll - Go Collimated or Go Home. Some people collect things for a hobby. Geeks collect hobbies. ScarletDME - The red hot Data Management Environment A Multi-Value database for the masses, not the classes. http://scarlet.deltasoft.com - Get it _today_!

Reply by email

Marco van de Voort
to Graeme Geldenhuys: As Marco said, you can use the "users" unit. Here is an example of how I use in in fpGUI,…

In our previous episode, Graeme Geldenhuys said:

Show quoted text 8 lines
As Marco said, you can use the "users" unit. Here is an example of how I use in in fpGUI, and it supports 32-bit and 64-bit systems. https://github.com/graemeg/fpGUI/blob/develop/src/corelib/x11/fpg_x11.pas#L4010-L4044 Note though that it only works for Linux. So other UNIX-type systems like FreeBSD and Solaris are not supported.

FreeBSD is mostly supported, though two units (shadow and crypth) and some calls relating to shadow passwords in users are not.

Reply by email

Graeme Geldenhuys
to Marco van de Voort
Marco van de Voort wrote
FreeBSD is mostly supported, though two units (shadow and crypth) and some calls relating to shadow passwords in users are not.

Thanks for the information Marco. I'll take a look.

Regards,
Graeme

Reply by email