Sponsored Content
Full Discussion: SUID bit???
Top Forums Programming SUID bit??? Post 7615 by Perderabo on Friday 28th of September 2001 09:17:50 AM
Old 09-28-2001
Use the symbolic name rather than the octal constant. And use a bitwise "and":

Code:
if (buf->stmode & S_ISUID) {
     printf{"suid bit set\n");
} else {
     printf("suid bit clear\n");
}

Some people don't like that form and think this is more clear:
if ((buf->stmode & S_ISUID) == S_ISUID)
 

6 More Discussions You Might Find Interesting

1. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies

2. UNIX for Dummies Questions & Answers

what is SUID,GUID and Sticky bit?

Dear all, what is SUID,GUID and Sticky bit permission? can anyone gave me explanation with example? thanks in advance.. (2 Replies)
Discussion started by: masthan25
2 Replies

3. UNIX for Dummies Questions & Answers

find files with SUID bit turned on

I'm writing a script that will search for files with the SUID bit turned on, and put the list in a file called id.txt i read that files with the SUID bit turned on are chmod'd to 4000, so i tried: find / -perm 4000 > id.txt also various others such as -perm 4777 etc etc but it found nothing... (1 Reply)
Discussion started by: SoVi3t
1 Replies

4. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

5. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

6. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies
chown(2)							System Calls Manual							  chown(2)

NAME
chown, lchown, fchown - Changes the owner and group IDs of a file SYNOPSIS
#include <unistd.h> int chown( const char *path, uid_t owner, gid_t group ); int lchown( const char *path, uid_t owner, gid_t group ); int fchown( int filedes, uid_t owner, gid_t group ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: chown(): POSIX.1, XPG4, XPG4-UNIX fchown(): POSIX.1, XPG4-UNIX lchown(): POSIX.1, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the name of the file whose owner ID, group ID, or both are to be changed. When the path parameter refers to a symbolic link, the behaviors of the chown() and the lchown() functions differ. The chown() function changes the ownership of the file pointed to by the sym- bolic link. The lchown() function changes the ownership of the symbolic link file itself. Specifies a valid open file descriptor. Speci- fies a numeric value representing the owner ID. Specifies a numeric value representing the group ID. DESCRIPTION
The chown(), lchown() and fchown() functions change the owner and group of a file. A process can change the value of the owner ID of a file only if the process has superuser privilege. A process can change the value of the file group ID if the effective user ID of the process matches the owner ID of the file, or if the process has superuser privilege. A process without superuser privilege can change the group ID of a file only to the value of its effective group ID or to a value in its sup- plementary group list. If the value of the owner ID is changed and the process does not have superuser privilege, the set-user ID attribute (the S_ISUID bit) of a regular file is cleared. The set-user ID attribute (S_ISUID bit) of a file is cleared upon successful return if: The file is a regular file. The process does not have superuser privilege. The set-group ID attribute (S_ISGID bit) of a file is cleared upon successful return if: The file is a regular file. The process does not have superuser privilege. If the owner or group parameter is specified as (uid_t)-1 or (gid_t)-1 respectively, the corresponding ID of the file is unchanged. Upon successful completion, the chown(), lchown(), and fchown() functions mark the st_ctime field of the file for update. RETURN VALUES
Upon successful completion, the chown(), lchown(), and fchown() functions return a value of 0 (zero). Otherwise, a value of -1 is returned, the owner and group of the file remain unchanged, and errno is set to indicate the error. ERRORS
If the chown() and lchown() functions fail, errno may be set to one of the following values: Search permission is denied on a component of path. The path parameter is an invalid address. The owner or group ID is not a value supported by this implementation. Too many links were encountered in translating path. The length of the path argument exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The path parameter does not exist or is an empty string. A component of path is not a directory. The effective user ID does not match the ID of the owner of the file, and the calling process does not have appropriate privilege and _POSIX_CHOWN_RESTRICTED indicates that such privilege is required. The named file resides on a read-only file system. The process' root or current directory is located in a virtual file system that has been unmounted. If the fchown() function fails, errno may be set to one of the following values: The file descriptor filedes is not valid. The owner or group ID is not a value supported by this implementation. RELATED INFORMATION
Functions: chmod(2) Commands: chown(1) Standards: standards(5) delim off chown(2)
All times are GMT -4. The time now is 04:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy