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
GETPWNAM(P)						     POSIX Programmer's Manual						       GETPWNAM(P)

NAME
getpwnam, getpwnam_r - search user database for a name SYNOPSIS
#include <pwd.h> struct passwd *getpwnam(const char *name); int getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result); DESCRIPTION
The getpwnam() function shall search the user database for an entry with a matching name. The getpwnam() function need not be reentrant. A function that is not required to be reentrant is not required to be thread-safe. Applications wishing to check for error situations should set errno to 0 before calling getpwnam(). If getpwnam() returns a null pointer and errno is non-zero, an error occurred. The getpwnam_r() function shall update the passwd structure pointed to by pwd and store a pointer to that structure at the location pointed to by result. The structure shall contain an entry from the user database with a matching name. Storage referenced by the structure is allocated from the memory provided with the buffer parameter, which is bufsize bytes in size. The maximum size needed for this buffer can be determined with the {_SC_GETPW_R_SIZE_MAX} sysconf() parameter. A NULL pointer shall be returned at the location pointed to by result on error or if the requested entry is not found. RETURN VALUE
The getpwnam() function shall return a pointer to a struct passwd with the structure as defined in <pwd.h> with a matching entry if found. A null pointer shall be returned if the requested entry is not found, or an error occurs. On error, errno shall be set to indicate the error. The return value may point to a static area which is overwritten by a subsequent call to getpwent(), getpwnam(), or getpwuid(). If successful, the getpwnam_r() function shall return zero; otherwise, an error number shall be returned to indicate the error. ERRORS
The getpwnam() and getpwnam_r() functions may fail if: EIO An I/O error has occurred. EINTR A signal was caught during getpwnam(). EMFILE {OPEN_MAX} file descriptors are currently open in the calling process. ENFILE The maximum allowable number of files is currently open in the system. The getpwnam_r() function may fail if: ERANGE Insufficient storage was supplied via buffer and bufsize to contain the data to be referenced by the resulting passwd structure. The following sections are informative. EXAMPLES
Getting an Entry for the Login Name The following example uses the getlogin() function to return the name of the user who logged in; this information is passed to the getpw- nam() function to get the user database entry for that user. #include <sys/types.h> #include <pwd.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> ... char *lgn; struct passwd *pw; ... if ((lgn = getlogin()) == NULL || (pw = getpwnam(lgn)) == NULL) { fprintf(stderr, "Get of user information failed. "); exit(1); } ... APPLICATION USAGE
Three names associated with the current process can be determined: getpwuid( geteuid()) returns the name associated with the effective user ID of the process; getlogin() returns the name associated with the current login activity; and getpwuid( getuid()) returns the name associ- ated with the real user ID of the process. The getpwnam_r() function is thread-safe and returns values in a user-supplied buffer instead of possibly using a static data area that may be overwritten by each call. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
getpwuid() , the Base Definitions volume of IEEE Std 1003.1-2001, <limits.h>, <pwd.h>, <sys/types.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 GETPWNAM(P)
All times are GMT -4. The time now is 06:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy