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 735165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:27:26+00:00 2026-05-14T07:27:26+00:00

I have a file src.tar.gz whoes owner and group are named src. When I

  • 0

I have a file src.tar.gz whoes owner and group are named “src”.
When I run test.c compiled with name “test” (permission: -rwsr-xr-x owner:root group:staff)

The way I run it:
I am running it as group member under “src” group.
But I run “test” as root since “test” permission is -rwsr-xr-x

Question:
Why did result come out like this? is the src.tar.gz group should be “src”?

Output:

Error: my group: src
Error: src.tar.gz group is root

test.c

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <grp.h>

void main(int ac, char **args) {

        const char *ERR_MSG_FORMAT = "%s: %s %s.\n";
        char *ptr_source_file = "src.tar.gz";
        struct stat src_stat;
        gid_t  src_gid, my_gid;

        int i = stat(ptr_source_file, &src_stat);
                my_gid = getgid();
                struct group *cur_gr = getgrgid(my_gid);
                fprintf(stderr, ERR_MSG_FORMAT, "Error", "my group: ", cur_gr->gr_name);

                src_gid = src_stat.st_gid;
                struct group *src_gr = getgrgid(src_gid);
                fprintf(stderr, ERR_MSG_FORMAT, "Error","src.tar.gz group is ", src_gr->gr_name);

}
  • 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-14T07:27:26+00:00Added an answer on May 14, 2026 at 7:27 am

    Always check return values of functions. Maybe stat() failed and you get st_gid 0 just because there was 0 before.

    For me the program works good.

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

Sidebar

Related Questions

I have the following For loop in a batch file: for /R c:\test\src %%i
I have some project with file: src/Test.cpp . Now I make subproject for it
We have an XSD file along with some java src files. How can we
I have a java app, and the log4j.properties file is in src/com/my/path/props. On compile,
I have a function that copies binary file public static void copyFile(String Src, String
I have file with name contact.php, inside I have form: <form method=post name=kontakt action=send_mail.php>
I have the following regex type in my xsd file: <xsd:simpleType name="Host"> <xsd:restriction base="xsd:string">
def antBuilder = new AntBuilder() antBuilder.tar(basedir: getOutputDirectory(), destfile: getTarFile()) antBuilder.gzip(src: getTarFile(), destfile: getTarGzipFile()) antBuilder.delete(file:
I have this file: #src/Jander/JanderBundle/resources/config/doctrine/metadata/orm/ Propuestas.orm.yml Propuestas: type: entity table: propuestas fields: id: id:
I have file /project/src/config/configInterface.java . In neighboring directory ( /project/src/anotherfolder/hereItryToUse.java ) I can't use

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.