Sponsored Content
Special Forums UNIX and Linux Applications Virtualization and Cloud Computing Custom ACL for S3 buckets and keys. Post 302382576 by linuxpenguin on Wednesday 23rd of December 2009 08:20:35 PM
Old 12-23-2009
Custom ACL for S3 buckets and keys.

Recently I realized that s3cmd (ubuntu) does not let you have custom acl's on s3 objects. So I wrote the following ruby script and I thought I could share with you all. Using s3fox, s3hub etc was really painful.

Code:
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'

key = ARGV[0] ## they key that you want to add ACL to. e.g. foo.txt
bucket = "<your_bucket_name>"
user_id = "<id_of_theobject>" ## It is a little tricky to get this one.
name = "<display_name_of_the_user>"
perms = "<Permissions you want in the ACL>" ## e.g. READ

AWS::S3::Base.establish_connection!(
  :access_key_id     => "<key_id>",
  :secret_access_key => "<access_key>"
)

policy = AWS::S3::S3Object.acl( key, bucket )
grant = AWS::S3::ACL::Grant.new
grantee = AWS::S3::ACL::Grantee.new
grant.grantee = grantee
grant.permission = perms
policy.grants << grant
grantee.type = "CanonicalUser"
grantee.id = user_id
grantee.display_name = name
AWS::S3::S3Object.acl( key, bucket , policy)

## And thats it, run s3cmd info /<BUCKET>/<key> to see the new ACL.


Last edited by Scott; 12-23-2009 at 11:08 PM.. Reason: sharing code tags :)
 

9 More Discussions You Might Find Interesting

1. Cybersecurity

ACL

Hi all, I've just been handled the responsibility for a FTP-site. Having no experiens of UNIX at all. And now one of my users needs to have full access to the usr directory and all it's subdirectories, don't know why just trying to do what the boss tells me. The type of UNIX is FreeBSD and the... (4 Replies)
Discussion started by: -tri-
4 Replies

2. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies

3. Shell Programming and Scripting

Need help to create ACL

Hi, I generated a script that will create the list of dir/sub-dir and will allow to create the same on diff server. this is what i have done : #!/bin/ksh # Script to migrate the directory between the two servers. # Ver 0.1 # Author Krishna. D # c - create and e - extract directory if ;... (1 Reply)
Discussion started by: krishnadvn
1 Replies

4. Linux

ACL

Hi, I want to know what does the "effective" comment means in the output of the getfacl and whether it has to do with the acl mask... thanks (0 Replies)
Discussion started by: Gartlar
0 Replies

5. Shell Programming and Scripting

What are public keys in ssh and how do we create the public keys??

Hi All, I am having knowledge on some basics of ssh and wanted to know what are the public keys and how can we create and implement it in connecting server. Please provide the information for the above, it would be helpful for me. Thanks, Ravindra (1 Reply)
Discussion started by: ravi3cha
1 Replies

6. Solaris

ACL

Can i get the synopsis for add multiple users in single command for ACL access for a directory or a file thanks in advance dinu (3 Replies)
Discussion started by: dinu
3 Replies

7. UNIX for Advanced & Expert Users

Need assistance on ACL

Hi Friends, I went through the ACL threads that were posted in the past but none were matching to my requirement . Hence starting a new thread . Challenge : user : a group : Test1 user: b group: Test2 Say under user a i create dir /tmp/debug with the privilege of 755 and also... (3 Replies)
Discussion started by: leobreaker
3 Replies

8. UNIX for Dummies Questions & Answers

ACL concept

Hi.. Could someone explain about setfacl,getfacl in unix and its uses. Regards, Suresh (1 Reply)
Discussion started by: suresh sunkara
1 Replies

9. Solaris

ACL on the Solaris

we have two Solaris 10 servers with same configuration and settings. We have hard mounted the NFS with the version 4. In one of the server the newer ACL commands are working fine (chmod and ls -v) whereas in another only posix (getfacl and setfacl alone is working) when we try ls -V in in that... (13 Replies)
Discussion started by: sathishbabu89
13 Replies
ACL_DELETE_ENTRY(3)					   BSD Library Functions Manual 				       ACL_DELETE_ENTRY(3)

NAME
acl_delete_entry -- delete an ACL entry from an ACL LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/acl.h> int acl_delete_entry(acl_t acl, acl_entry_t entry_d); DESCRIPTION
The acl_delete_entry() function is a POSIX.1e call that removes the ACL entry entry_d from ACL acl. RETURN VALUES
The acl_delete_entry() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The acl_delete_entry() function fails if: [EINVAL] Argument acl does not point to a valid ACL. Argument entry_d is not a valid descriptor for an ACL entry in acl. SEE ALSO
acl(3), acl_copy_entry(3), acl_get_entry(3), posix1e(3) STANDARDS
POSIX.1e is described in IEEE POSIX.1e draft 17. AUTHORS
Michael Smith Chris D Fulhaber BSD
March 10, 2001 BSD
All times are GMT -4. The time now is 11:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy