Sponsored Content
Top Forums UNIX for Advanced & Expert Users allow user to use sudo cp on a specific directory and only a specific file Post 302553907 by NH2 on Friday 9th of September 2011 06:53:29 AM
Old 09-09-2011
Kind of, but may not offer all the flexibility you want. For instance, to allow user nh2 to copy foo to /home/bar, put in your /etc/sudoers file
Code:
nh2  ALL=(ALL) NOPASSWD: /bin/cp foo /home/bar

Drawbacks are (among others):
  1. cp is not as flexible; for instance I have to use exactly the syntax set in the sudoers file. Eventually this means using absolute path for the file to copy.
  2. access right might need fixing. Depending on your requirement, plain cp or using the '-p' option for cp might be enough.

HTH,
/Lew
 

10 More Discussions You Might Find Interesting

1. Solaris

give user permission on specific directory in solaris

dear all does any one give any user write permission using access control list or another way to solve this problem (1 Reply)
Discussion started by: murad.jaber
1 Replies

2. Solaris

when FTP user will go to specific directory

Hi experts, I have a user "bingo" in my sunsolaris 9. # /etc/passwd bingo:x:513:1::/export/home/bingo:/bin/bash when anyone Telnet to this user it goes to his home directory /export/home/bingo But now i want- when someone FTP to this user "bingo" it will NOT go to his home dir. Rather it... (5 Replies)
Discussion started by: thepurple
5 Replies

3. UNIX for Dummies Questions & Answers

granting permission to file/directory to a specific user

hello, I would like to grant full access to a directory which is owned by root and the web application that created it. I have though of adding the permission to the whole world, but for security reason I would like to grant it to one more user. I have tried this 'chmod -U newUser+wrx... (2 Replies)
Discussion started by: run123
2 Replies

4. Solaris

create user with RWX access to a specific directory in Solaris 10

I need to create a user account for a developer that will allow him rwx access to all resources in a directory. How can I do that? Thanks (5 Replies)
Discussion started by: gsander
5 Replies

5. Solaris

User permission to a specific directory only

is is possible to grant user access to only one subdirectory? example a. create ftp user with read/write/delete access (ftp user doesnt belong to uguys group) $ cd /etc/mydir $ls file1 file2 $ls -al -rw-rw-r-x 2 unixguy uguys 96 Dec 8 12:53 file1 -rw-rw-r-x 2 unixguy uguys 96 Dec 8... (1 Reply)
Discussion started by: lhareigh890
1 Replies

6. Solaris

How to restrict user to a specific directory in solaris 10

Hi all, I want to create a new user and grant him ONLY transfer files access to a specific directory where he can only upload and read the files. He should be restricted to this activity only. Regards (6 Replies)
Discussion started by: gilldn
6 Replies

7. Solaris

Limit FTP user's access to a specific directory

Hi, I have searched "Limit FTP user's access to a specific directory" subject for 3 days. I found proftp and vsftp but i couldn't compile and install. Is there any idea. Please suggest. (6 Replies)
Discussion started by: hamurd
6 Replies

8. Solaris

Limit bash/sh user's access to a specific directory

Hello Team, I have Solaris 10 u6 I have a user test1 using bash that belong to the group staff. I would like to restrict this user to navigate only in his home directory and his subfolders but not not move out to other directories. How can I do it ? Thanks in advance (1 Reply)
Discussion started by: csierra
1 Replies

9. UNIX for Advanced & Expert Users

Change sFTP home directory for particular user and from specific server

Hello Folks, Of course i came here for your favour :) How to set a defalult home directory for sFTP login ( at present users land in to their home directrory) when they connect from specific server. When server(A) sFTP's to Linux server(B) they land to thier home directory. I want... (5 Replies)
Discussion started by: Thala
5 Replies

10. UNIX for Beginners Questions & Answers

Is there a way to restrict a user (owner) to execute scripts from a specific directory

Hello, I have a user Bob on a RHEL 7 server1. Where his script area is "/home/Bob/scripts/" and he is the owner for this directory. On the server1, there is a NFS mount from another server2, with path as "/global/work/" and Bob is the owner for this directory too in server2. (Same UID and GID... (5 Replies)
Discussion started by: karumudi7
5 Replies
Template::Plugin::File(3)				User Contributed Perl Documentation				 Template::Plugin::File(3)

NAME
Template::Plugin::File - Plugin providing information about files SYNOPSIS
[% USE File(filepath) %] [% File.path %] # full path [% File.name %] # filename [% File.dir %] # directory DESCRIPTION
This plugin provides an abstraction of a file. It can be used to fetch details about files from the file system, or to represent abstract files (e.g. when creating an index page) that may or may not exist on a file system. A file name or path should be specified as a constructor argument. e.g. [% USE File('foo.html') %] [% USE File('foo/bar/baz.html') %] [% USE File('/foo/bar/baz.html') %] The file should exist on the current file system (unless "nostat" option set, see below) as an absolute file when specified with as leading '"/"' as per '"/foo/bar/baz.html"', or otherwise as one relative to the current working directory. The constructor performs a "stat()" on the file and makes the 13 elements returned available as the plugin items: dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks e.g. [% USE File('/foo/bar/baz.html') %] [% File.mtime %] [% File.mode %] ... In addition, the "user" and "group" items are set to contain the user and group names as returned by calls to "getpwuid()" and "getgrgid()" for the file "uid" and "gid" elements, respectively. On Win32 platforms on which "getpwuid()" and "getgrid()" are not available, these values are undefined. [% USE File('/tmp/foo.html') %] [% File.uid %] # e.g. 500 [% File.user %] # e.g. abw This user/group lookup can be disabled by setting the "noid" option. [% USE File('/tmp/foo.html', noid=1) %] [% File.uid %] # e.g. 500 [% File.user %] # nothing The "isdir" flag will be set if the file is a directory. [% USE File('/tmp') %] [% File.isdir %] # 1 If the "stat()" on the file fails (e.g. file doesn't exists, bad permission, etc) then the constructor will throw a "File" exception. This can be caught within a "TRY...CATCH" block. [% TRY %] [% USE File('/tmp/myfile') %] File exists! [% CATCH File %] File error: [% error.info %] [% END %] Note the capitalisation of the exception type, '"File"', to indicate an error thrown by the "File" plugin, to distinguish it from a regular "file" exception thrown by the Template Toolkit. Note that the "File" plugin can also be referenced by the lower case name '"file"'. However, exceptions are always thrown of the "File" type, regardless of the capitalisation of the plugin named used. [% USE file('foo.html') %] [% file.mtime %] As with any other Template Toolkit plugin, an alternate name can be specified for the object created. [% USE foo = file('foo.html') %] [% foo.mtime %] The "nostat" option can be specified to prevent the plugin constructor from performing a "stat()" on the file specified. In this case, the file does not have to exist in the file system, no attempt will be made to verify that it does, and no error will be thrown if it doesn't. The entries for the items usually returned by "stat()" will be set empty. [% USE file('/some/where/over/the/rainbow.html', nostat=1) [% file.mtime %] # nothing METHODS
All "File" plugins, regardless of the "nostat" option, have set a number of items relating to the original path specified. path The full, original file path specified to the constructor. [% USE file('/foo/bar.html') %] [% file.path %] # /foo/bar.html name The name of the file without any leading directories. [% USE file('/foo/bar.html') %] [% file.name %] # bar.html dir The directory element of the path with the filename removed. [% USE file('/foo/bar.html') %] [% file.name %] # /foo ext The file extension, if any, appearing at the end of the path following a '"."' (not included in the extension). [% USE file('/foo/bar.html') %] [% file.ext %] # html home This contains a string of the form '"../.."' to represent the upward path from a file to its root directory. [% USE file('bar.html') %] [% file.home %] # nothing [% USE file('foo/bar.html') %] [% file.home %] # .. [% USE file('foo/bar/baz.html') %] [% file.home %] # ../.. root The "root" item can be specified as a constructor argument, indicating a root directory in which the named file resides. This is otherwise set empty. [% USE file('foo/bar.html', root='/tmp') %] [% file.root %] # /tmp abs This returns the absolute file path by constructing a path from the "root" and "path" options. [% USE file('foo/bar.html', root='/tmp') %] [% file.path %] # foo/bar.html [% file.root %] # /tmp [% file.abs %] # /tmp/foo/bar.html rel(path) This returns a relative path from the current file to another path specified as an argument. It is constructed by appending the path to the '"home"' item. [% USE file('foo/bar/baz.html') %] [% file.rel('wiz/waz.html') %] # ../../wiz/waz.html EXAMPLES
[% USE file('/foo/bar/baz.html') %] [% file.path %] # /foo/bar/baz.html [% file.dir %] # /foo/bar [% file.name %] # baz.html [% file.home %] # ../.. [% file.root %] # '' [% file.abs %] # /foo/bar/baz.html [% file.ext %] # html [% file.mtime %] # 987654321 [% file.atime %] # 987654321 [% file.uid %] # 500 [% file.user %] # abw [% USE file('foo.html') %] [% file.path %] # foo.html [% file.dir %] # '' [% file.name %] # foo.html [% file.root %] # '' [% file.home %] # '' [% file.abs %] # foo.html [% USE file('foo/bar/baz.html') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # '' [% file.home %] # ../.. [% file.abs %] # foo/bar/baz.html [% USE file('foo/bar/baz.html', root='/tmp') %] [% file.path %] # foo/bar/baz.html [% file.dir %] # foo/bar [% file.name %] # baz.html [% file.root %] # /tmp [% file.home %] # ../.. [% file.abs %] # /tmp/foo/bar/baz.html # calculate other file paths relative to this file and its root [% USE file('foo/bar/baz.html', root => '/tmp/tt2') %] [% file.path('baz/qux.html') %] # ../../baz/qux.html [% file.dir('wiz/woz.html') %] # ../../wiz/woz.html AUTHORS
Michael Stevens wrote the original "Directory" plugin on which this is based. Andy Wardley split it into separate "File" and "Directory" plugins, added some extra code and documentation for "VIEW" support, and made a few other minor tweaks. COPYRIGHT
Copyright 2000-2007 Michael Stevens, Andy Wardley. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin, Template::Plugin::Directory, Template::View perl v5.12.1 2008-11-13 Template::Plugin::File(3)
All times are GMT -4. The time now is 07:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy