Sponsored Content
Top Forums UNIX for Advanced & Expert Users Elevated privilege output redirection Post 302237201 by jim mcnamara on Wednesday 17th of September 2008 07:34:43 AM
Old 09-17-2008
OR sudo a chmod command that will allow writing -- plus, all of this sounds very much like a security breach in the making. Why are you writing to some type of conf file as a plain user? Do you want all unprivileged users to be able to change files that used to be protected?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Standard output and redirection

Hello, Is is possible to redirect stdout to a file as well as to the console/screen or display in ksh. any thoughts suggestions/input is appreciated. Thanks. (2 Replies)
Discussion started by: jerardfjay
2 Replies

2. Shell Programming and Scripting

Redirection of output (for logging)

Hi, Currently I'm working on a lenghty script so I figured it would be useful to create a logfile so that output that is displayed on the users screen is also stored in the log file for later reference...... kinda like the whole point of a log file! Anyway, I was just wondering if there was an... (3 Replies)
Discussion started by: _Spare_Ribs_
3 Replies

3. UNIX for Dummies Questions & Answers

Output file redirection

Suppose I have a file named a When I write cat a>a The following error message is displayed cat: a: input file is output file and my file a is truncated to zero size. Also the exit status of the last command is 1 Can someone tell me what actually happens when I do so? (1 Reply)
Discussion started by: aagajaba
1 Replies

4. Shell Programming and Scripting

redirection and output

I'm redirecting the output of a command to a logfile, however, if the user is on a terminal I would also like the output to be displayed on the screen. tar tvf some_tarfile >Logfile if the user is on a term then have the output to the Logfile and also be displayed on the screen at the same... (2 Replies)
Discussion started by: nck
2 Replies

5. Shell Programming and Scripting

Redirection output

Hi there I have a script that runs but it outputs everything onto the screen instead of a file. I've tried using the > outputfile.txt however all it does is dump the output to the screen and creates an outputfile.txt but doesn't put anything in that file. Any help would be appreciated ... (6 Replies)
Discussion started by: kma07
6 Replies

6. Shell Programming and Scripting

Output redirection

We have an application here that does some table queries and then prints the result on screen. I do not have the code of this application (which i will just call "queryCommand"), but what it does is that you call it with some parameters and it prints some info about the query and then the... (5 Replies)
Discussion started by: jolateh
5 Replies

7. UNIX for Dummies Questions & Answers

Output redirection

Hello i am trying to write a script that will redirect the output to a certain file. Here is the code so far: #!/bin/bash ps -e | sort | more > psfile When I execute the script nothing happens since i assume the output was redirected to the file called psfile. When I try to look at the... (1 Reply)
Discussion started by: mfruiz34
1 Replies

8. Shell Programming and Scripting

Redirection of ls -l output

Hi I am making a script where i want to redirect the output of ls -l to a file Example #ls -l fil1.txt > /opt/temp/a.txt ac: No such file or directory I want to capture output of this command like here output is ac: No such file or directory can anyone help (4 Replies)
Discussion started by: anish19
4 Replies

9. Shell Programming and Scripting

output redirection

Hi all I was wondering if there was a slicker way of doing this without the file - awk '{print $2}' FS=":" "${FILE}" > "${TMPFILE}" { read M_GRP_ID || m_fail 1 "Error: Read failed 1 (${FUNCNAME})" read M_GRP_WAIT || m_fail 1 "Error: Read failed 2 (${FUNCNAME})" }... (6 Replies)
Discussion started by: steadyonabix
6 Replies

10. Shell Programming and Scripting

For loop output redirection

Hi All, i have below for loop of which i am trying to redirect output in a file: for i in `/usr/sbin/ifconfig -a | awk '/flags/ {print $1}' | grep -v lo | sed 's/://g'` do ifconfig $i dhcp status done >> /tmp/logfile but instead the output is appearing as stdout on screen rather than... (12 Replies)
Discussion started by: omkar.jadhav
12 Replies
chmod(2)							System Calls Manual							  chmod(2)

Name
       chmod, fchmod - change mode of file

Syntax
       #include <sys/types.h>
       #include <sys/stat.h>

       chmod(path, mode)
       char *path;
       mode_t mode;

       fchmod(fd, mode)
       int fd;
       mode_t mode;

Description
       The  file  whose  name is provided by path or referenced by the descriptor fd has its mode changed to mode.  Modes are constructed by ORing
       combinations of the following:

       S_ISUID	   - 04000  set user ID on execution

       S_ISGID	   - 02000  set group ID on execution

       S_ISVTX	   - 01000  save text image after execution

       S_IRUSR	   - 00400  read by owner

       S_IWUSR	   - 00200  write by owner

       S_IXUSR	   - 00100  execute (search on directory) by owner

       S_IRWXG	   - 00070  read, write, execute (search) by group

       S_IRWXO	   - 00007  read, write, execute (search) by others

       If an executable file is set up for sharing (the default), the mode S_ISVTX prevents the system from abandoning the swap-space image of the
       program-text portion of the file when its last user terminates.	The ability to set this bit is restricted to the superuser.

       If  the	mode  S_ISVTX  (sticky	bit)  is set on a directory, an unprivileged user cannot delete or the rename files of other users in that
       directory.  For more information on the sticky bit, see

       Only the owner of a file or the superuser can change the mode.

       Writing a file or changing the owner of a file clears the set-user-id and set-group-id bits of that file. Turning off  these  bits  when  a
       file is written or its owner changed protects the file from remaining set-user-id or set-group-id after being modified. If a file, specifi-
       cally a program, remained set-user-id or set-group-id after being modified, that file could allow unauthorized access  to  other  files	or
       accounts.

Environment
   System Five
       ELOOP is a possible error condition.

Return Values
       Upon successful completion, a value of 0 is returned.  Otherwise, a value of -1 is returned, and is set to indicate the error.

Diagnostics
       The system call fails and the file mode remains unchanged under the following conditions:

       [EACCES]       Search permission is denied on a component of the path prefix.

       [EFAULT]       The path argument points outside the process's allocated address space.

       [EIO]	      An I/O error occurred while reading from or writing to the file system.

       [ELOOP]	      Too many symbolic links were encountered in translating the pathname.

       [ENAMETOOLONG] A pathname component exceeds 255 characters, or an entire pathname exceeds 1023 characters.

       [ENOENT]       The named file does not exist.

       [ENOTDIR]      A component of the path prefix is not a directory.

       [EPERM]	      The effective user ID does not match the owner of the file and the effective user ID is not the superuser.

       [EROFS]	      The named file resides on a read-only file system.

       [ESTALE]       The  file  handle  given in the argument is invalid.  Either the file referred to by that file handle no longer exists or it
		      has been revoked.

       The system call fails under the following conditions:

       [EBADF]	      The descriptor is not valid.

       [EINVAL]       The fd refers to a socket, not to a file.

       [EIO]	      An I/O error occurred while reading from or writing to the file system.

       [EROFS]	      The file resides on a read-only file system.

       [ETIMEDOUT]    A connect request or remote file operation failed because the connected party did not respond after a period of time  deter-
		      mined by the communications protocol.

See Also
       open(2), chown(2)

																	  chmod(2)
All times are GMT -4. The time now is 03:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy