C, parsing /etc/passwd, getting userids

Member

Posts:Location:Joined: 01.01.70 Rank: Guest

Posted on 06-09-08 13:09

Hello, I've been working on creating a linux shell. I figured that I should have it customizable like other shells. So, I figured that I should put a customizable file in the home directory. I am going to use getuid() to get the current user id and then find a matching user id in /etc/passwd and take the corresponding home directory. However, I don't seem to be parsing correctly. This is what I have: http://pastebin.c. . .. That's the code and what happens when I run it. Does anyone have any ideas? I can't seem to find any logic in it at all.

Edit:
Nevermind, I got it. Using fscanf with %s sucks, had to go through with fgetc(f);.

Edited by on 06-09-08 20:53

Hellbound Hackers is the collective work of the staff and the community and is therefore licensed under the CC BY-NC-SA license.