GETPW(3) Linux Programmer's Manual GETPW(3)NAME
getpw - Re-construct password line entry
SYNOPSIS
#include <pwd.h>
#include <sys/types.h>
int getpw(uid_t uid, char *buf);
DESCRIPTION
The getpw() function re-constructs the password line entry for the given user uid uid in the buffer buf. The returned buffer contains a
line of format
name:passwd:uid:gid:gecos:dir:shell
The passwd structure is defined in <pwd.h> as follows:
struct passwd {
char *pw_name; /* user name */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user id */
gid_t pw_gid; /* group id */
char *pw_gecos; /* real name */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
RETURN VALUE
The getpw() function returns 0 on success, or -1 if an error occurs.
ERRORS
ENOMEM Insufficient memory to allocate passwd structure.
FILES
/etc/passwd
password database file
CONFORMING TO
SYSVr2.
BUGS
The getpw() function is dangerous as it may overflow the provided buffer buf. It is obsoleted by getpwuid().
SEE ALSO fgetpwent(3), getpwent(3), setpwent(3), endpwent(3), getpwnam(3), getpwuid(3), putpwent(3), passwd(5)GNU 1996-05-27 GETPW(3)
Check Out this Related Man Page
GETPW(3) Linux Programmer's Manual GETPW(3)NAME
getpw - reconstruct password line entry
SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <sys/types.h>
#include <pwd.h>
int getpw(uid_t uid, char *buf);
DESCRIPTION
The getpw() function reconstructs the password line entry for the given user ID uid in the buffer buf. The returned buffer contains a line
of format
name:passwd:uid:gid:gecos:dir:shell
The passwd structure is defined in <pwd.h> as follows:
struct passwd {
char *pw_name; /* username */
char *pw_passwd; /* user password */
uid_t pw_uid; /* user ID */
gid_t pw_gid; /* group ID */
char *pw_gecos; /* user information */
char *pw_dir; /* home directory */
char *pw_shell; /* shell program */
};
For more information about the fields of this structure, see passwd(5).
RETURN VALUE
The getpw() function returns 0 on success; on error, it returns -1, and errno is set to indicate the error.
If uid is not found in the password database, getpw() returns -1, sets errno to 0, and leaves buf unchanged.
ERRORS
0 or ENOENT
No user corresponding to uid.
EINVAL buf is NULL.
ENOMEM Insufficient memory to allocate passwd structure.
FILES
/etc/passwd
password database file
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+----------+---------------+----------------+
|Interface | Attribute | Value |
+----------+---------------+----------------+
|getpw() | Thread safety | MT-Safe locale |
+----------+---------------+----------------+
CONFORMING TO
SVr2.
BUGS
The getpw() function is dangerous as it may overflow the provided buffer buf. It is obsoleted by getpwuid(3).
SEE ALSO endpwent(3), fgetpwent(3), getpwent(3), getpwnam(3), getpwuid(3), putpwent(3), setpwent(3), passwd(5)COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU 2017-09-15 GETPW(3)
Hey all,
Just found your forum...Looks super rich with info! Can't wait to get through it all.
I am currently writing a web app in .net that telnets into a unix server (require uid + passwd), runs a command, and returns that output to be displayed on the web page.
I have gotten through the... (8 Replies)
hi,
I get an output like
uid=user1
gecos=user
uid=user2
gecos=admin
gecos=sol admin
uid=user3
uid=user4
gecos=sol, admin
and need it modified to:
uid=user1
gecos=user (3 Replies)
How do i go about getting the uid of the user and verify ?
if
then
echo "You are not a superuser, please login as a superuser"
exit1;
fi
the above code doesn't work. can some guru please help me.
1. how to get the uid of the user ? i know by typing id but how to... (7 Replies)
i want to cut all the entries from the /etc/passwd file in which the uid is> 500
for this i was writing this ,m quiet new to all this.. scripting
but on the 6th n 8th line ,, i hav to specify a line number .. to get the commnd working .. but i want to use variable i instead of that ,,... (2 Replies)
Greetings,
I need to find few patterns related to password (pwsd, pwd, password etc) in a directory includig sub -directories.
I need to redirect the output of find (in combination with grep) to a file which will be later used to verify the files.
OS is Sun Solaris 5.10.
The out put file format... (3 Replies)
i need a script to process a password file and based on the UIDs in the password file, generate the new UID that is 1 greater than the highest uid.
i have some script logic but i dont really understand it. any help?
#!/usr/bin/perl
##########################################
#... (3 Replies)
i am prompting for a name to search.
read user
if
then
however, i get this error:
please enter a username on the system:
fool
menu_script2.sh: line 123: (4 Replies)
Hi all,
Yet another problem on one of my nodes.
I am unable to open my password file .It shows some junk alphabets.
root@ecosdp26a>cat /etc/passwd... (10 Replies)
Hi all,
In Unix shell script i am connecting to oracle database and it is executing fine,
my problem is my user name and password is visible for all, how to hide.
Note -- username and password is hard coded, it is my requirement
example--
#!/bin/sh
------
------
sqlplus uname/pwd... (4 Replies)
Hello guys
I am about to write a script that is based on "The Linux Administration Handbook" The exercise is as follows:
Write a shell script to help monitor the health of the /etc/passwd file.
Find entries that have UID0
Find entries that have no password (needs /etc/shadow)
Find any... (4 Replies)
Hello,
i need to pass the variable in place of pwd. how to display variable in the bleow syntax.
suppose, passwd="test", then 'id/$passwd.....
FEDFlagResult=`sqlplus -S 'id/pwd@(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1643))(CONNECT_DATA= (SID=peta1)))'<< EOF
select... (4 Replies)
Hello,
I would like to copy the first and third char on each line of a file and place them in the 14h and 17th char positions. The file name is listed first and is 6 char's and the dir name is second and also same char size on each line.
The file has thousands of lines.
Initial... (6 Replies)