Hi,
Thanks foe the information. I have created the file
/etc/nsswitch.conf and tried to run the same application, then perror is
printing success, but the password structure address remains 0. My
program and output is given below
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <pwd.h>
int main()
{
uid_t uid = 0;
struct passwd *pw=NULL;
uid=getuid();
pw=getpwuid(uid);
perror("error no is");
printf("uid is ===> %d\n",uid);
printf("pw is ===> %d\n",pw);
}
error is ===>: Success
uid is ===> 0
pw is ===> 0
I have tried with getpwnam("root") also, but result ramins same..
Thanks
Tomy Devasia
Manish Katiyar wrote:
On Thu, Feb 21, 2008 at 7:53 PM, tomy <tomy@xxxxxxxxxxxx> wrote:
hi,
While printing the error it displaying " No such file or directory".
What is the default file for getpwuid?...
The man page says this :
NOTE
The user password database mostly refers to /etc/passwd.
However, with recent systems it also refers to network wide databases
using NIS, LDAP and other local files as configured in
/etc/nsswitch.conf.
FILES
/etc/passwd
local password database file
/etc/nsswitch.conf
System Databases and Name Service Switch configuration file
Thanks
Martin Mancuska wrote:
> Did you try to print errno value ?
>
> martin
>
> 2008/2/21, tomy <tomy@xxxxxxxxxxxx>:
>
>> In my application
>>
>> #include <unistd.h>
>> #include <sys/types.h>
>> #include <stdio.h>
>> int main()
>> {
>> uid_t uid;
>> struct passwd *pw=NULL;
>> uid=getuid();
>> pw=(struct passwd *)getpwuid(uid);
>> printf("uid is %d\n",uid);
>> printf("Password structure addr is %d",pw);
>> }
>>
>> Output is
>> uid is 0
>> Password structure addr is 0
>> Why this is happening?.....
>>
>> --
>> Thanks & Regards
>>
>> Tomy Devasia
>> Product Devpt & Support
>> Kalki Communication Technologies Ltd
>> Bangalore
>> India
>>
>>
>>
>> --
>> To unsubscribe from this list: send an email with
>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>
>>
>>
>
>
>
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ