Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:52:22+00:00 2026-05-25T20:52:22+00:00

I need to write a program, part of which involves checking if the userid

  • 0

I need to write a program, part of which involves checking if the userid of the person executing the program exists in the ACL file of a file which the program uses. That is, this program writes into the file and only users whose ID and privileges are entered in the ACL are allowed to do so. How can the program check this? I know that I need to use the getresid function to get the RUID of the executing process, but how do I check this value against all the values stored in the ACL? Please help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:52:23+00:00Added an answer on May 25, 2026 at 8:52 pm

    If I misunderstood the question I apologize, but hopefully you will find this helpful:

    Exceprt from some acl documentation:

    The following functions retrieve and manipulate ACL entries:

    acl_copy_entry()
    acl_create_entry()
    acl_delete_entry()
    acl_first_entry()
    acl_get_entry()
    

    The following functions retrieve and manipulate fields in an ACL entry:

    acl_add_perm() 
    acl_clear_perm()
    alc_delete_perm() 
    acl_get_permset() 
    acl_get_qualifier() 
    acl_get_tag_type() 
    acl_set_permset() 
    acl_set_qualifier() 
    acl_set_tag_type()
    

    …

    ACL Entries

    An ACL entry consists of the following fields:

    Tag type (defined in the acl.h header file):

    ACL_USER_OBJ – The owning user entry.

    ACL_GROUP_OBJ – The owning group entry.

    ACL_USER – An entry for other users.

    ACL_GROUP – An entry for other groups.

    ACL_OTHER_OBJ – The entry for all users and groups that are not included in another entry.

    Tag qualifier – The qualifier value for a ACL_USER entry is a user ID.

    The qualifier value for a ACL_GROUP entry is a group ID.
    The qualifier value for any of the *_OBJ entries is NULL.

    From acl_update.c:

    /* 
    Find the the ACL entry in 'acl' corresponding to the tag type and
       qualifier in 'tag' and 'id'. Return the matching entry, or NULL
       if no entry was found. */
    
    static acl_entry_t
    findEntry(acl_t acl, acl_tag_t tag, id_t qaul)
    {
        acl_entry_t entry;
        acl_tag_t entryTag;
        uid_t *uidp;
        gid_t *gidp;
        int ent, s;
    
        for (ent = ACL_FIRST_ENTRY; ; ent = ACL_NEXT_ENTRY) {
            s = acl_get_entry(acl, ent, &entry);
            if (s == -1)
                errExit("acl_get_entry");
    
            if (s == 0)
                return NULL;
    
            if (acl_get_tag_type(entry, &entryTag) == -1)
                errExit("acl_get_tag_type");
    
            if (tag == entryTag) {
                if (tag == ACL_USER) {
                    uidp = acl_get_qualifier(entry);
                    if (uidp == NULL)
                        errExit("acl_get_qualifier");
    
                    if (qaul == *uidp) {
                        if (acl_free(uidp) == -1)
                            errExit("acl_free");
                        return entry;
                    } else {
                        if (acl_free(uidp) == -1)
                            errExit("acl_free");
                    }
    
                } else if (tag == ACL_GROUP) {
                    gidp = acl_get_qualifier(entry);
                    if (gidp == NULL)
                        errExit("acl_get_qualifier");
    
                    if (qaul == *gidp) {
                        if (acl_free(gidp) == -1)
                            errExit("acl_free");
                        return entry;
                    } else {
                        if (acl_free(gidp) == -1)
                            errExit("acl_free");
                    }
    
                } else {
                    return entry;
                }
            }
        }
    }
    

    I dont think u need to check the ACL of a specific file, but if I am wrong, here is some info to do so:

    $ getfacl myFile 
    # file: myFile
    # owner: jon
    # group: people
    user::rwx
    user:foo:rwx
    group::rwx
    mask::rwx
    other::--- 
    

    then to get a uid from the name (untested but should be close):

    $ grep /etc/passwd `getfacl myFile | grep owner | split -d":" -f2` | egrep -o "[0-9]+"
    

    Some more resources:

    acl/facl examples and reference
    man acl

    POSIX Access Control Lists

    statacl

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a program that uses matrix multiplication to rotate an image
I'm going to need to write a program that takes a list of persons
I need to write a small program that can detect that it has been
I need to write a little program in C that parses a string. I
I need to write a simple program for work that does the following: read
I need to write a simple program that records all the input from parallel
I need to write a program. A part of the program is to write
I've got a contract to write part of a program. The person writing the
I need to write a program used internally where different users will have different
i need to write a program in c# to collect information about processes running

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.