Question on file owner name representation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Question on file owner name representation
# 1  
Old 05-27-2010
Java Question on file owner name representation

Hi All,

I came across a situation where i saw a directory name given below:

Code:
 
drwxrwxrwx 5 121973 staff 8192 Apr 26 23:47 arunpr

Just for your info:
1. All our application user ids are LDAP.
2. Hence we will not see any details of user in /etc/passwd file and i believe this could not be the reason since other directories and user/owner names a re properly displayed.

My question here is: how/when/why the numbers comes in place instead of user/owner name.

Thanks a lot in advance!
# 2  
Old 05-27-2010
It's quite possible to have files belonging to users or groups with no corresponding entry in /etc/passwd or /etc/group, nothing prevents it. Anything with sufficient privileges can create files belonging to any ID and group whether represented by anything in passwd or group or not; those only control login permissions through the traditional login system.
Code:
touch this ; sudo chown 9999 this

All users and groups are just numbers anyway. If ls doesn't find matching entries in passwd and/or group it will just display numbers. As long as whatever login manager involved sets correct access permissions on login based on the relevant user and group numbers, and the numbers used internally and externally don't overlap, things can be kept consistent without knowing all names locally.

Last edited by Corona688; 05-27-2010 at 12:17 PM..
# 3  
Old 05-28-2010
Hi Corona688,

Thanks for the information!
As i said in my earlier note, all of the application users are maintained through LDAP. Since LDAP no users information are maintained in /etc/passwd file. However, if i create a file or diectory and it is having my name(owner name) and all other settings as normal. Almost all users have proper info on their files/dirs. Only few users having numbers as per my example and they are also LDAP.

Please clarify me and let me know if you need any other info from my end to clarify me.

Thanks a lot for your valuable time!
# 4  
Old 05-28-2010
I had come across similar senario , where the use is removed from the server but the directory owned by the user exists.

In this case i had seen the number instead of username.
# 5  
Old 05-28-2010
Hi,

Thanks for the info!
I thought the same but in my case, all user s are LDAP and not maintained locally. So how system determines that this user has been deleted and let represent the userid as number. And for your information, still many user directories/files are showing properly with userid/owner name in its properties.

Thanks a lot for your time! Please advise.
# 6  
Old 05-28-2010
Quote:
Originally Posted by Arunprasad
I thought the same but in my case, all user s are LDAP and not maintained locally. So how system determines that this user has been deleted and let represent the userid as number. And for your information, still many user directories/files are showing properly with userid/owner name in its properties.

Thanks a lot for your time! Please advise.
It's abstracted behind the getpwent() call and its related calls, looks like:
Code:
GETPWENT(3)                Linux Programmer's Manual               GETPWENT(3)



NAME
       getpwent, setpwent, endpwent - get password file entry

SYNOPSIS
       #include <sys/types.h>
       #include <pwd.h>

       struct passwd *getpwent(void);

       void setpwent(void);

       void endpwent(void);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       getpwent(), setpwent(), endpwent(): _BSD_SOURCE || _SVID_SOURCE ||
       _XOPEN_SOURCE > = 500

DESCRIPTION
       The getpwent() function returns a pointer to a structure containing the
       broken-out  fields  of  a  record from the password database (e.g., the
       local password file /etc/passwd, NIS, and LDAP).  The first time it  is
       called  it  returns  the first entry; thereafter, it returns successive
       entries.

...

So ls doesn't reach in and grab login names from /etc/passwd manually, it just calls getpwent() from glibc, which is capable of getting login info from any valid sources. Finding no corresponding UID in either, ls just prints the UID/GID.

Didn't know getpwent() did that. That's a pretty good reason to use these functions instead of just parsing /etc/passwd yourself!
# 7  
Old 05-31-2010
Thanks a lot for providing more background!

It seems the above is related to Linux anyways i believe thats a not a big deal here.
I am worried about why the ls is not listing the user name for specific ID alone and returns the user name for other files/directories successfully or why the getpwent() fails to retrieve this alone.

Again, all user id's are LDAP sourced.

Please advise.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Graphical Representation of mpstat.out file

hi everyone, We've generated mpstat.out file monitoring cpu utilization and the file is ready now.Wanted to generate graphical charts for the same output data. Can anyone pleas suggest tool for the same.? (1 Reply)
Discussion started by: Kathraji
1 Replies

2. Solaris

Privileges : modify dir/file owner by other that's not owner

i need to do the following operations in solaris 10: 1.change owner and group owner for files which are not owned by the current user and user group 2.to can delete files in the /tmp directory which are not of the current user 3. allow to a standard user the deletion of files in the /tmp... (1 Reply)
Discussion started by: sirmark
1 Replies

3. Cybersecurity

Change file owner

What i did: - logged in with acc1 and created a new user acc2 commands used: useradd and passwd. - Then i logged in acc2. but all the files are owned by acc1. Issue: I try to change the owner of the files using chown command . But it gives me a error message. All i want to do is... (13 Replies)
Discussion started by: TotallyConfused
13 Replies

4. UNIX for Advanced & Expert Users

How UNIX admin set up this? how files of 744 of other owner can be removed by another owner?

Hi all, We have some files are under 744 permissions and the the owner is say owner1 and group1. Now we have another user owner2 of group2, owner2 can remove files of the owner1 and the permission of those files are 744, unix admin told us he did some config at his side so we can do that. ... (14 Replies)
Discussion started by: TheGunMan
14 Replies

5. Shell Programming and Scripting

getting file owner in perl

hi, how can I get the owner of the file ( not uid) on windows plaform. "getpwuid" is not working on windows. I knw it works on unix. Thanks. (2 Replies)
Discussion started by: shellwell
2 Replies

6. UNIX for Advanced & Expert Users

Is there a command to get the owner of a file?

At the moment I'm just using `ls -o` (with `cut`), but `ls` is obviously giving me a lot more output than just the file owner. (9 Replies)
Discussion started by: Bilge
9 Replies

7. Shell Programming and Scripting

determine owner of a file

Hello, I am on a mission to determine the user of file. I have used the ls -l command but it displays permission, link, user, group, etc, but I just want to display just the name of user of a specified file. Many thanks (4 Replies)
Discussion started by: unibboy
4 Replies

8. Solaris

Owner of file gets 'not owner' error for chgrp

Hi Folks, I know that changing users and groups is pretty basic admin, but this one has got me stumped. When I try to change the group of a file for which I am the owner for, it still gives me a 'Not owner' error. For example, when I am logged in as 'webadmin', I have the following file: ... (4 Replies)
Discussion started by: brizrobbo
4 Replies

9. UNIX for Dummies Questions & Answers

change owner of a file

im running into changing the ownership of a file. I am trying to change the ownership to "system", but it doesn't want to work. I sudo chown system /preferences.plist Password: chown: system: Invalid argument is there a way to read the ownership of a file, something like read chown... (3 Replies)
Discussion started by: CBarraford
3 Replies

10. UNIX for Dummies Questions & Answers

How to change the owner of the file?

How to change the owner of the file? Can I change the owner of file/ files? I am user and not admin.(not logged as root) (1 Reply)
Discussion started by: redlotus72
1 Replies
Login or Register to Ask a Question