Sponsored Content
Top Forums Programming Getpwnam_r returning null with errno 25 Post 302813405 by jim mcnamara on Monday 27th of May 2013 08:04:48 AM
Old 05-27-2013
There is a problem here. ENOTTY is not an error you can get from calling getpwnam().

The problem has to have occurred before that call. Therefore, errno was set to ENOTTY before you called getpwnam().
 

10 More Discussions You Might Find Interesting

1. Programming

errno pb

Hello, I need to make a lib with pthread, when I run my make file all is good. But when I run my test program, I test errno in the begining and is already set to 251. Is it normal ??? What can I modify in my Makefile to have errno set to 0 ??? Thanks $make gcc -D_REENTRANT -shared -fpic... (3 Replies)
Discussion started by: dts
3 Replies

2. Solaris

malloc returning NULL if freemem high & swapmem low

Hi All, In my application malloc is returning NULL even though there is sufficient amount of free memory is available but swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ?:) Kindly look into... (5 Replies)
Discussion started by: Ritesh Kumar
5 Replies

3. UNIX for Dummies Questions & Answers

malloc returning NULL if freemem high & swapmem low (MPRAS version 3.03 )

Hi All,:) In my application malloc is returning NULL even though there is sufficient amount of free memory available but the swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ? Few details: ... (4 Replies)
Discussion started by: Ritesh Kumar
4 Replies

4. Programming

errno

Hey, Can I assume that for certain function calls, errno can never be set to a certain value. More specifically, can I assume that for if the stat function call fails, the errno can never be or "No space left on device." I am assuming that a read function cannot fail because of no space... (5 Replies)
Discussion started by: the_learner
5 Replies

5. Programming

getservbyport - Always returning NULL servent

Hi, I am having an issue using getservbyport. Here is a little program to demonstrate the problem (removed the includes): int main(void) { struct servent *service; int memsize = sizeof(struct servent); service = (struct servent *)malloc(memsize); ... (2 Replies)
Discussion started by: goon12
2 Replies

6. Shell Programming and Scripting

Script returning null results

Hi, The following shell script returning null results could you please tell me whats the problem in script, ********************************* #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties a=`date +"%y%m%d"` set -x for i in `cat... (2 Replies)
Discussion started by: shivanete
2 Replies

7. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

8. UNIX for Advanced & Expert Users

getservbyname returning NULL

OS : Solaris 10 When I try to get the "echo" service port, getservbyname is returning null. I checked - /etc/services having an entry for echo - echo 7/tcp (But still getservbyname returning null) Any other config required to consider? (1 Reply)
Discussion started by: satish@123
1 Replies

9. Programming

Malloc function returning NULL

Hi All, I am using malloc function for allocating dynamic memory. When I am using below code on Linux server its working fine, but When I am trying the same code on HP UNIX server its returning NULL. below is a fragment of code in which it is giving problem. tmp = (format_tree... (4 Replies)
Discussion started by: Taher Saifuddin
4 Replies

10. AIX

Errno.h symbols

Hi, I need to look at a recent copy of /usr/include/errno.h from AIX 7.2 to check some symbols. In particular, I'm curious if it defines EOWNERDEAD and ENOTRECOVERABLE. Can someone who has access to 7.2 please check for me? Thanks! (1 Reply)
Discussion started by: topcat
1 Replies
GETPWENT(3)						   BSD Library Functions Manual 					       GETPWENT(3)

NAME
getpwent, getpwent_r, getpwnam, getpwnam_r, getpwuid, getpwuid_r, setpassent, setpwent, endpwent -- password database operations LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <pwd.h> struct passwd * getpwent(void); int getpwent_r(struct passwd *pw, char *buffer, size_t buflen, struct passwd **result); struct passwd * getpwnam(const char *name); int getpwnam_r(const char *name, struct passwd *pw, char *buffer, size_t buflen, struct passwd **result); struct passwd * getpwuid(uid_t uid); int getpwuid_r(uid_t uid, struct passwd *pw, char *buffer, size_t buflen, struct passwd **result); int setpassent(int stayopen); void setpwent(void); void endpwent(void); DESCRIPTION
These functions operate on the password database which is described in passwd(5). Each entry in the database is defined by the structure passwd found in the include file <pwd.h>: struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* encrypted password */ uid_t pw_uid; /* user uid */ gid_t pw_gid; /* user gid */ time_t pw_change; /* password change time */ char *pw_class; /* user login class */ char *pw_gecos; /* general information */ char *pw_dir; /* home directory */ char *pw_shell; /* default shell */ time_t pw_expire; /* account expiration */ }; The functions getpwnam() and getpwuid() search the password database for the given user name pointed to by name or user id pointed to by uid respectively, always returning the first one encountered. Identical user names or user ids may result in undefined behavior. The getpwent() function sequentially reads the password database and is intended for programs that wish to process the complete list of users. The functions getpwnam_r(), getpwuid_r(), and getpwent_r() act like their non re-entrant counterparts, updating the contents of pw and stor- ing a pointer to that in result, and returning 0. Storage used by pw is allocated from buffer, which is buflen bytes in size. If the requested entry cannot be found, result will point to NULL and 0 will be returned. If an error occurs, a non-zero error number will be returned and result will point to NULL. Calling getpwent_r() from multiple threads will result in each thread reading a disjoint portion of the password database. The setpassent() function accomplishes two purposes. First, it causes getpwent() to ``rewind'' to the beginning of the database. Addition- ally, if stayopen is non-zero, file descriptors are left open, significantly speeding up subsequent accesses for all of the functions. (This latter functionality is unnecessary for getpwent() as it doesn't close its file descriptors by default.) It is dangerous for long-running programs to keep the file descriptors open as the database will become out of date if it is updated while the program is running. The setpwent() function is equivalent to setpassent() with an argument of zero. The endpwent() function closes any open files. These functions have been written to ``shadow'' the password file, e.g. allow only certain programs to have access to the encrypted password. If the process which calls them has an effective uid of 0, the encrypted password will be returned, otherwise, the password field of the returned structure will point to the string '*'. RETURN VALUES
The functions getpwent(), getpwnam(), and getpwuid(), return a valid pointer to a passwd structure on success and a NULL pointer if the entry was not found or an error occured. If an error occured, the global variable errno is set to indicate the nature of the failure. The setpassent() function returns 0 on failure, setting the global variable errno to indicate the nature of the failure, and 1 on success. The endpwent() and setpwent() functions have no return value. The functions getpwnam_r(), getpwuid_r(), and getpwent_r() return 0 on success or entry not found, and non-zero on failure, setting the global variable errno to indicate the nature of the failure. FILES
/etc/pwd.db The insecure password database file /etc/spwd.db The secure password database file /etc/master.passwd The current password file /etc/passwd A Version 7 format password file COMPATIBILITY
The historic function setpwfile() which allowed the specification of alternative password databases, has been deprecated and is no longer available. ERRORS
The following error codes may be set in errno for getpwent, getpwent_r, getpwnam, getpwnam_r, getpwuid, getpwuid_r, and setpassent: [EINTR] A signal was caught during the database search. [EIO] An I/O error has occurred. [EMFILE] The limit on open files for this process has been reached. [ENFILE] The system limit on open files has been reached. The following error code may be set in errno for getpwent_r, getpwnam_r, and getpwuid_r: [ERANGE] The resulting struct passwd does not fit in the space defined by buffer and buflen Other errno values may be set depending on the specific database backends. SEE ALSO
getlogin(2), getgrent(3), nsswitch.conf(5), passwd(5), passwd.conf(5), pwd_mkdb(8), vipw(8) STANDARDS
The getpwnam() and getpwuid(), functions conform to ISO/IEC 9945-1:1990 (``POSIX.1''). The getpwnam_r() and getpwuid_r() functions conform to IEEE Std 1003.1c-1995 (``POSIX.1''). The endpwent(), getpwent(), and setpwent() functions conform to X/Open Portability Guide Issue 4, Version 2 (``XPG4.2'') and IEEE Std 1003.1-2004 (``POSIX.1'') (XSI extension). HISTORY
The getpwent, getpwnam, getpwuid, setpwent, and endpwent functions appeared in Version 7 AT&T UNIX. The setpassent function appeared in 4.3BSD-Reno. The functions getpwnam_r() and getpwuid_r() appeared in NetBSD 3.0. BUGS
The functions getpwent(), getpwnam(), and getpwuid(), leave their results in an internal static object and return a pointer to that object. Subsequent calls to any of these functions will modify the same object. The functions getpwent(), endpwent(), setpassent(), and setpwent() are fairly useless in a networked environment and should be avoided, if possible. getpwent() makes no attempt to suppress duplicate information if multiple sources are specified in nsswitch.conf(5). BSD
April 30, 2008 BSD
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy