Class: ACL::Entry

Inherits:
Object
  • Object
show all
Defined in:
ext/acl/acl.c,
ext/acl/acl.c

Overview

ACL::Entry represents single entry of ACL.

Entries have the formL tag_type, permset, qualifier.

Instance Method Summary collapse

Instance Method Details

#=(source) ⇒ Object

copy ACL::Entry into another

entries can be in different ACLs

call-seq:

dest_entry = source_entry


301
302
303
304
305
306
307
308
309
310
311
# File 'ext/acl/acl.c', line 301

VALUE ruby_acl_copy_entry( VALUE self, VALUE source ) {
  acl_entry_t acl_dest, acl_source;

  Data_Get_Struct_ex( self,   acl_entry_t, acl_dest );
  Data_Get_Struct_ex( source, acl_entry_t, acl_source );

  if (0 != acl_copy_entry(acl_dest, acl_source)) {
    rb_sys_fail("acl_copy_entry failed");
  }
  return self;
}

#permsetObject

get ACL::Entry permisions



253
254
255
256
257
258
259
260
261
262
# File 'ext/acl/acl.c', line 253

VALUE ruby_acl_entry_get_permset( VALUE self ) {
  acl_entry_t acl_entry;
  acl_permset_t acl_permset;
  
  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );
  if (0 != acl_get_permset(acl_entry, &acl_permset)) {
    rb_sys_fail("acl_get_permset failed");
  }
  return INT2FIX(*(int*)acl_permset);
}

#permset=(val) ⇒ Object

set ACL::Entry permisions



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'ext/acl/acl.c', line 267

VALUE ruby_acl_entry_set_permset( VALUE self, VALUE val ) {
  acl_entry_t acl_entry;
  acl_permset_t acl_permset;
  int perms;

  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );

  if (0 != acl_get_permset(acl_entry, &acl_permset))
    rb_sys_fail("acl_get_permset failed");
  if (0 != acl_clear_perms(acl_permset))
    rb_sys_fail("acl_clear_perms failed");

  perms = FIX2INT(val);
  //#define set_perm(perm) if (0!=acl_add_perm(acl_permset,perm)) rb_sys_fail("acl_add_perm failed")
  //if (perms & 0x01) set_perm(ACL_EXECUTE);
  //if (perms & 0x02) set_perm(ACL_WRITE);
  //if (perms & 0x04) set_perm(ACL_READ);
  if (0!=acl_add_perm(acl_permset,perms))
    rb_sys_fail("acl_add_perm failed");

  if (0 != acl_set_permset(acl_entry, acl_permset )) {
    rb_sys_fail("acl_set_permset failed");
  }
  return self;
}

#qualifierObject

get ACL::Entry qualifier



192
193
194
195
196
197
198
199
200
201
202
203
# File 'ext/acl/acl.c', line 192

VALUE ruby_acl_entry_get_qualifier( VALUE self ) {
  acl_entry_t acl_entry;
  int *ret;
  VALUE val;
  
  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );
  ret = acl_get_qualifier(acl_entry);
  if ( NULL == ret ) return Qnil;
  val = INT2FIX( *ret );
  acl_free( ret );
  return val;
}

#qualifier=(val) ⇒ Object

set ACL::Entry qualifier

call-seq:

entry.qualifier = uid
entry.qualifier = gid


213
214
215
216
217
218
219
220
221
222
# File 'ext/acl/acl.c', line 213

VALUE ruby_acl_entry_set_qualifier( VALUE self, VALUE val ) {
  int data;
  acl_entry_t acl_entry;
  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );
  data = FIX2INT(val);
  if (0 != acl_set_qualifier(acl_entry, &data)) {
    rb_sys_fail("acl_set_qualifier failed");
  }
  return self;
}

#tag_typeObject

get ACL::Entry tag type



227
228
229
230
231
232
233
234
235
236
# File 'ext/acl/acl.c', line 227

VALUE ruby_acl_entry_get_tag_type( VALUE self ) {
  acl_entry_t acl_entry;
  acl_tag_t acl_tag;
  
  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );
  if (0 != acl_get_tag_type(acl_entry, &acl_tag)) {
    rb_sys_fail("acl_set_qualifier failed");
  }
  return INT2FIX( acl_tag );
}

#tag_type=(val) ⇒ Object

set ACL::Entry tag type



241
242
243
244
245
246
247
248
# File 'ext/acl/acl.c', line 241

VALUE ruby_acl_entry_set_tag_type( VALUE self, VALUE val ) {
  acl_entry_t acl_entry;
  Data_Get_Struct_ex( self, acl_entry_t, acl_entry );
  if (0 != acl_set_tag_type(acl_entry, FIX2INT(val))) {
    rb_sys_fail("acl_set_tag_type failed");
  }
  return self;
}