Why umask in C program doen't work as expected

Clash Royale CLAN TAG#URR8PPP up vote
0
down vote
favorite
I have the following code comes from the apue book:
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int
main()
S_IWGRP
In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :
$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo
But it should be like this :
$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo
So what's going on? Why the umask in my program doesn't work?
permissions umask
 |Â
show 1 more comment
up vote
0
down vote
favorite
I have the following code comes from the apue book:
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int
main()
S_IWGRP
In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :
$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo
But it should be like this :
$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo
So what's going on? Why the umask in my program doesn't work?
permissions umask
1
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have the following code comes from the apue book:
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int
main()
S_IWGRP
In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :
$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo
But it should be like this :
$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo
So what's going on? Why the umask in my program doesn't work?
permissions umask
I have the following code comes from the apue book:
#define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
int
main()
S_IWGRP
In terminal, I first all umask to get the current mode creation :
I get 0002.
Then run this program. I get the following :
$ ls -l foo bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 bar
-rwxrwxrwx. 1 root root 0 May 15 14:28 foo
But it should be like this :
$ ls -l foo bar
-rw------- 1 sar 0 Dec 7 21:20 bar
-rw-rw-rw- 1 sar 0 Dec 7 21:20 foo
So what's going on? Why the umask in my program doesn't work?
permissions umask
asked May 15 at 6:53
Sut
9
9
1
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32
 |Â
show 1 more comment
1
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32
1
1
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036401%2fwhy-umask-in-c-program-doent-work-as-expected%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Are the files on an NTFS/FAT32 file system?
â muru
May 15 at 6:58
I run it in WSL of windows and also in Fedora in VMware. Both get this result.@muru
â Sut
May 15 at 7:03
Fedora is off-topic here, and the question about the filesystem still applies.
â muru
May 15 at 7:03
Oh I get the right result. It is the problem of the file system. Maybe the problem comes to the shared folder interface with VMware. When I move the code into another folder, both the Ubuntu and Fedora works fine. Thank you very much!
â Sut
May 15 at 7:07
@Sut whe"re did you move it to? an EXT4 partition?
â Fabby
May 17 at 4:32