shared-macros.mk: simplify java settings
[oi-userland.git] / components / library / gnome-vfs / patches / gnome-vfs-10-acl-zfs.patch
blob60506d6b9fddd28b0f0e6284411b13061f444c4a
1 --- gnome-vfs-2.17.2-orig/configure.in 2007-04-10 01:50:02.575026000 +0200
2 +++ gnome-vfs-2.17.2-alo/configure.in 2007-04-03 12:35:51.151289000 +0200
3 @@ -1048,7 +1018,7 @@
4 dnl End of IPv6 checks
5 dnl ==============================================================================
7 -PKG_CHECK_MODULES(LIBGNOMEVFS, glib-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED gthread-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libxml-2.0 >= $XML_REQUIRED gnome-mime-data-2.0 $dbus_requirement)
8 +PKG_CHECK_MODULES(LIBGNOMEVFS, glib-2.0 >= $GLIB_REQUIRED gmodule-no-export-2.0 >= $GLIB_REQUIRED gthread-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libxml-2.0 >= $XML_REQUIRED gnome-mime-data-2.0 dbus-glib-1 >= 0.60)
9 LIBGNOMEVFS_CFLAGS="$LIBGNOMEVFS_CFLAGS $OPENSSL_CFLAGS $LIBGNUTLS_CFLAGS $HOWL_CFLAGS $AVAHI_CFLAGS"
10 LIBGNOMEVFS_LIBS="$LIBGNOMEVFS_LIBS $OPENSSL_LIBS $LIBGNUTLS_LIBS $HOWL_LIBS $AVAHI_LIBS $RESOLVER_LIBS"
11 AC_SUBST(LIBGNOMEVFS_CFLAGS)
12 @@ -1122,52 +1092,10 @@
13 AC_CHECK_FUNCS(acl_extended_file)
15 AC_CHECK_HEADERS([pwd.h])
16 - if test "$ac_cv_header_pwd_h" = "yes"; then
17 - AC_CACHE_CHECK([for posix getpwuid_r],
18 - ac_cv_func_posix_getpwuid_r,
19 - [AC_TRY_RUN([
20 -#include <errno.h>
21 -#include <pwd.h>
22 -int main () {
23 - char buffer[10000];
24 - struct passwd pwd, *pwptr = &pwd;
25 - int error;
26 - errno = 0;
27 - error = getpwuid_r (0, &pwd, buffer,
28 - sizeof (buffer), &pwptr);
29 - return (error < 0 && errno == ENOSYS)
30 - || error == ENOSYS;
31 -} ],
32 - [ac_cv_func_posix_getpwuid_r=yes],
33 - [ac_cv_func_posix_getpwuid_r=no])])
34 - dnl GLIB_ASSERT_SET(ac_cv_func_posix_getpwuid_r)
35 - if test "$ac_cv_func_posix_getpwuid_r" = yes; then
36 - AC_DEFINE(HAVE_POSIX_GETPWUID_R,1,
37 - [Have POSIX function getpwuid_r])
38 - else
39 - AC_CACHE_CHECK([for nonposix getpwuid_r],
40 - ac_cv_func_nonposix_getpwuid_r,
41 - [AC_TRY_LINK([#include <pwd.h>],
42 - [char buffer[10000];
43 - struct passwd pwd;
44 - getpwuid_r (0, &pwd, buffer,
45 - sizeof (buffer));],
46 - [ac_cv_func_nonposix_getpwuid_r=yes],
47 - [ac_cv_func_nonposix_getpwuid_r=no])])
48 - dnl GLIB_ASSERT_SET(ac_cv_func_nonposix_getpwuid_r)
49 - if test "$ac_cv_func_nonposix_getpwuid_r" = yes; then
50 - AC_DEFINE(HAVE_NONPOSIX_GETPWUID_R,1,
51 - [Have non-POSIX function getpwuid_r])
52 - fi
53 - fi
54 - fi
56 - AC_CHECK_HEADERS([grp.h])
57 + FW_CHECK_PWD
59 - AC_CHECK_FUNCS(getgrgid_r)
60 - AC_CHECK_FUNCS(getgrnam_r)
61 - AC_CHECK_FUNCS(getpwnam_r)
63 + AC_CHECK_HEADERS([grp.h])
64 + FW_CHECK_GRP
67 AC_SUBST(ACL_LIBS)
68 --- gnome-vfs-2.17.2-orig/acinclude.m4 2007-04-10 01:50:02.574820000 +0200
69 +++ gnome-vfs-2.17.2-alo/acinclude.m4 2007-04-03 12:35:48.071873000 +0200
70 @@ -554,5 +554,85 @@
75 dnl end of neon macros
78 +dnl
79 +dnl checks for password entry functions and header files
80 +dnl
81 +AC_DEFUN([FW_CHECK_PWD],
84 +HAVE_GETPWNAM_R=""
86 +AC_MSG_CHECKING(for getpwnam_r with 5 parameters)
87 +AC_TRY_COMPILE([#include <pwd.h>
88 +#include <stdlib.h>],
89 +getpwnam_r(NULL,NULL,NULL,0,NULL);,AC_DEFINE(HAVE_GETPWNAM_R_5,1,Some systems have getpwnam_r) AC_DEFINE(HAVE_GETPWNAM_R,1,Some systems have getpwnam_r) AC_MSG_RESULT(yes); HAVE_GETPWNAM_R="yes", AC_MSG_RESULT(no))
91 +if ( test -z "$HAVE_GETPWNAM_R" )
92 +then
93 + AC_MSG_CHECKING(for getpwnam_r with 4 parameters)
94 + AC_TRY_COMPILE([#include <pwd.h>
95 +#include <stdlib.h>],
96 +getpwnam_r(NULL,NULL,NULL,0);,AC_DEFINE(HAVE_GETPWNAM_R_4,1,Some systems have getpwnam_r) AC_DEFINE(HAVE_GETPWNAM_R,1,Some systems have getpwnam_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
97 +fi
99 +HAVE_GETPWUID_R=""
101 +AC_MSG_CHECKING(for getpwuid_r with 5 parameters)
102 +AC_TRY_COMPILE([#include <pwd.h>
103 +#include <stdlib.h>],
104 +getpwuid_r(0,NULL,NULL,0,NULL);,AC_DEFINE(HAVE_GETPWUID_R_5,1,Some systems have getpwuid_r) AC_DEFINE(HAVE_GETPWUID_R,1,Some systems have getpwuid_r) AC_MSG_RESULT(yes); HAVE_GETPWUID_R="yes", AC_MSG_RESULT(no))
106 +if ( test -z "$HAVE_GETPWUID_R" )
107 +then
108 + AC_MSG_CHECKING(for getpwuid_r with 4 parameters)
109 + AC_TRY_COMPILE([#include <pwd.h>
110 +#include <stdlib.h>],
111 +getpwuid_r(0,NULL,NULL,0);,AC_DEFINE(HAVE_GETPWUID_R_4,1,Some systems have getpwuid_r) AC_DEFINE(HAVE_GETPWUID_R,1,Some systems have getpwuid_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
117 +dnl
118 +dnl checks for group entry functions and header files
119 +dnl
120 +AC_DEFUN([FW_CHECK_GRP],
123 +HAVE_GETGRNAM_R=""
125 +AC_MSG_CHECKING(for getgrnam_r with 5 parameters)
126 +AC_TRY_COMPILE([#include <grp.h>
127 +#include <stdlib.h>],
128 +getgrnam_r(NULL,NULL,NULL,0,NULL);,AC_DEFINE(HAVE_GETGRNAM_R_5,1,Some systems have getgrnam_r) AC_DEFINE(HAVE_GETGRNAM_R,1,Some systems have getgrnam_r) AC_MSG_RESULT(yes); HAVE_GETGRNAM_R="yes", AC_MSG_RESULT(no))
130 +if ( test -z "$HAVE_GETGRNAM_R" )
131 +then
132 + AC_MSG_CHECKING(for getgrnam_r with 4 parameters)
133 + AC_TRY_COMPILE([#include <grp.h>
134 +#include <stdlib.h>],
135 +getgrnam_r(NULL,NULL,NULL,0);,AC_DEFINE(HAVE_GETGRNAM_R_4,1,Some systems have getgrnam_r) AC_DEFINE(HAVE_GETGRNAM_R,1,Some systems have getgrnam_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
138 +HAVE_GETGRGID_R=""
140 +AC_MSG_CHECKING(for getgrgid_r with 5 parameters)
141 +AC_TRY_COMPILE([#include <grp.h>
142 +#include <stdlib.h>],
143 +getgrgid_r(0,NULL,NULL,0,NULL);,AC_DEFINE(HAVE_GETGRGID_R_5,1,Some systems have getgrgid_r) AC_DEFINE(HAVE_GETGRGID_R,1,Some systems have getgrgid_r) AC_MSG_RESULT(yes); HAVE_GETGRGID_R="yes", AC_MSG_RESULT(no))
145 +if ( test -z "$HAVE_GETGRGID_R" )
146 +then
147 + AC_MSG_CHECKING(for getgrgid_r with 4 parameters)
148 + AC_TRY_COMPILE([#include <grp.h>
149 +#include <stdlib.h>],
150 +getgrgid_r(0,NULL,NULL,0);,AC_DEFINE(HAVE_GETGRGID_R_4,1,Some systems have getgrgid_r) AC_DEFINE(HAVE_GETGRGID_R,1,Some systems have getgrgid_r) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
157 --- gnome-vfs-2.17.2-orig/libgnomevfs/gnome-vfs-ace.c 2007-04-10 01:50:02.414610000 +0200
158 +++ gnome-vfs-2.17.2-alo/libgnomevfs/gnome-vfs-ace.c 2007-04-03 12:35:45.753157000 +0200
159 @@ -41,14 +41,15 @@
161 struct _GnomeVFSACEPrivate {
163 - GnomeVFSACLKind kind;
164 - char *id;
165 + GnomeVFSACLKind kind;
166 + GnomeVFSACLType type;
167 + GnomeVFSACLInherance inherance;
169 - PermSet perm_set;
171 - gboolean negative;
172 - gboolean inherit;
173 + char *id;
174 + PermSet perm_set;
176 +// gboolean negative;
177 +// gboolean inherit;
180 #define GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GNOME_VFS_TYPE_ACE, GnomeVFSACEPrivate))
181 @@ -82,8 +83,8 @@
182 PROP_KIND,
183 PROP_ID,
184 PROP_PERMS,
185 - PROP_NEGATIVE,
186 - PROP_INHERIT
187 + PROP_TYPE,
188 + PROP_INHERANCE
192 @@ -161,26 +162,31 @@
193 pspec);
197 - pspec = g_param_spec_boolean ("negative",
198 - "fixme",
199 - "fixme",
200 - FALSE,
201 - G_PARAM_READWRITE);
202 + pspec = g_param_spec_uint ("type",
203 + "fixme",
204 + "fixme",
205 + GNOME_VFS_ACL_TYPE_NULL,
206 + G_MAXUINT32,
207 + GNOME_VFS_ACL_TYPE_NULL,
208 + G_PARAM_READWRITE |
209 + G_PARAM_CONSTRUCT);
211 g_object_class_install_property (gobject_class,
212 - PROP_NEGATIVE,
213 + PROP_TYPE,
214 pspec);
217 - pspec = g_param_spec_boolean ("inherit",
218 - "fixme",
219 - "fixme",
220 - FALSE,
221 - G_PARAM_READWRITE);
222 + pspec = g_param_spec_uint ("inherance",
223 + "fixme",
224 + "fixme",
225 + GNOME_VFS_ACL_INHERANCE_NULL,
226 + G_MAXUINT32,
227 + GNOME_VFS_ACL_INHERANCE_NULL,
228 + G_PARAM_READWRITE |
229 + G_PARAM_CONSTRUCT);
231 g_object_class_install_property (gobject_class,
232 - PROP_INHERIT,
233 + PROP_INHERANCE,
234 pspec);
237 @@ -226,14 +232,14 @@
238 permset_set (&priv->perm_set, pset);
239 break;
241 - case PROP_INHERIT:
242 - priv->inherit = g_value_get_boolean (value);
243 + case PROP_TYPE:
244 + priv->type = g_value_get_uint (value);
245 break;
247 - case PROP_NEGATIVE:
248 - priv->negative = g_value_get_boolean (value);
250 + case PROP_INHERANCE:
251 + priv->inherance = g_value_get_uint (value);
252 break;
255 default:
256 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
258 @@ -263,12 +269,12 @@
259 g_value_set_pointer (value, priv->perm_set.perms);
260 break;
262 - case PROP_INHERIT:
263 - g_value_set_boolean (value, priv->inherit);
264 + case PROP_TYPE:
265 + g_value_set_uint (value, priv->type);
266 break;
268 - case PROP_NEGATIVE:
269 - g_value_set_boolean (value, priv->negative);
271 + case PROP_INHERANCE:
272 + g_value_set_uint (value, priv->inherance);
273 break;
275 default:
276 @@ -382,9 +388,11 @@
277 /* Public Interface */
279 GnomeVFSACE *
280 -gnome_vfs_ace_new (GnomeVFSACLKind kind,
281 - const char *id,
282 - GnomeVFSACLPerm *perms)
283 +gnome_vfs_ace_new (GnomeVFSACLKind kind,
284 + const char *id,
285 + GnomeVFSACLPerm *perms,
286 + GnomeVFSACLType type,
287 + GnomeVFSACLInherance inherance)
289 GnomeVFSACE *entry;
291 @@ -392,6 +400,8 @@
292 "kind", kind,
293 "id", id,
294 "permissions", perms,
295 + "type", type,
296 + "inherance", inherance,
297 NULL);
298 return entry;
300 @@ -426,40 +436,38 @@
301 priv->id = g_strdup (id);
304 -void
305 -gnome_vfs_ace_set_inherit (GnomeVFSACE *entry,
306 - gboolean inherit)
307 +GnomeVFSACLType
308 +gnome_vfs_ace_get_ace_type (GnomeVFSACE *entry)
310 - g_object_set (G_OBJECT(entry), "inherit", inherit, NULL);
311 + return entry->priv->type;
314 -gboolean
315 -gnome_vfs_ace_get_inherit (GnomeVFSACE *entry)
317 - gboolean inherit;
319 - g_object_get (G_OBJECT(entry), "inherit", &inherit, NULL);
320 - return inherit;
321 +void
322 +gnome_vfs_ace_set_ace_type (GnomeVFSACE *entry,
323 + GnomeVFSACLType type)
325 + entry->priv->type = type;
329 -void
330 -gnome_vfs_ace_set_negative (GnomeVFSACE *entry,
331 - gboolean negative)
332 +GnomeVFSACLInherance
333 +gnome_vfs_ace_get_inherance (GnomeVFSACE *entry)
335 - g_object_set (G_OBJECT(entry), "negative", negative, NULL);
336 + return entry->priv->inherance;
339 -gboolean
340 -gnome_vfs_ace_get_negative (GnomeVFSACE *entry)
342 - gboolean negative;
344 - g_object_get (G_OBJECT(entry), "negative", &negative, NULL);
345 - return negative;
346 +void
347 +gnome_vfs_ace_set_inherance (GnomeVFSACE *entry,
348 + GnomeVFSACLInherance inherance)
350 + entry->priv->inherance = inherance;
356 const GnomeVFSACLPerm *
357 gnome_vfs_ace_get_perms (GnomeVFSACE *entry)
359 @@ -576,9 +584,9 @@
360 priv_a = entry_a->priv;
361 priv_b = entry_b->priv;
364 return (priv_a->kind == priv_b->kind &&
365 g_str_equal_safe (priv_a->id, priv_b->id) &&
366 - priv_a->inherit == priv_b->inherit &&
367 - priv_a->negative == priv_b->negative);
368 + priv_a->inherance == priv_b->inherance &&
369 + priv_a->type == priv_b->type);
372 --- gnome-vfs-2.17.2-orig/libgnomevfs/gnome-vfs-ace.h 2007-04-10 01:50:02.395768000 +0200
373 +++ gnome-vfs-2.17.2-alo/libgnomevfs/gnome-vfs-ace.h 2007-04-03 12:35:45.001762000 +0200
374 @@ -61,13 +61,18 @@
376 typedef guint32 GnomeVFSACLKind;
377 typedef guint32 GnomeVFSACLPerm;
378 +typedef guint32 GnomeVFSACLType;
379 +typedef guint32 GnomeVFSACLInherance;
380 +typedef guint32 GnomeVFSACLScheme;
383 GType gnome_vfs_ace_get_type (void) G_GNUC_CONST;
385 GnomeVFSACE * gnome_vfs_ace_new (GnomeVFSACLKind kind,
386 const char *id,
387 - GnomeVFSACLPerm *perms);
388 + GnomeVFSACLPerm *perms,
389 + GnomeVFSACLType type,
390 + GnomeVFSACLInherance inherance);
392 GnomeVFSACLKind gnome_vfs_ace_get_kind (GnomeVFSACE *entry);
393 void gnome_vfs_ace_set_kind (GnomeVFSACE *entry,
394 @@ -76,18 +81,22 @@
395 const char * gnome_vfs_ace_get_id (GnomeVFSACE *entry);
396 void gnome_vfs_ace_set_id (GnomeVFSACE *entry,
397 const char *id);
399 -gboolean gnome_vfs_ace_get_inherit (GnomeVFSACE *entry);
400 -void gnome_vfs_ace_set_inherit (GnomeVFSACE *entry,
401 - gboolean inherit);
403 -gboolean gnome_vfs_ace_get_negative (GnomeVFSACE *entry);
404 -void gnome_vfs_ace_set_negative (GnomeVFSACE *entry,
405 - gboolean negative);
407 const GnomeVFSACLPerm * gnome_vfs_ace_get_perms (GnomeVFSACE *entry);
408 void gnome_vfs_ace_set_perms (GnomeVFSACE *entry,
409 GnomeVFSACLPerm *perms);
411 +GnomeVFSACLType gnome_vfs_ace_get_ace_type (GnomeVFSACE *entry);
412 +void gnome_vfs_ace_set_ace_type (GnomeVFSACE *entry,
413 + GnomeVFSACLType type);
415 +GnomeVFSACLInherance gnome_vfs_ace_get_inherance (GnomeVFSACE *entry);
416 +void gnome_vfs_ace_set_inherance (GnomeVFSACE *entry,
417 + GnomeVFSACLInherance inherit);
419 +gboolean gnome_vfs_ace_equal (GnomeVFSACE *entry_a,
420 + GnomeVFSACE *entry_b);
422 +/* Permission related */
423 void gnome_vfs_ace_add_perm (GnomeVFSACE *entry,
424 GnomeVFSACLPerm perm);
425 void gnome_vfs_ace_del_perm (GnomeVFSACE *entry,
426 @@ -97,8 +106,10 @@
427 void gnome_vfs_ace_copy_perms (GnomeVFSACE *source,
428 GnomeVFSACE *dest);
430 -gboolean gnome_vfs_ace_equal (GnomeVFSACE *entry_a,
431 - GnomeVFSACE *entry_b);
432 +/* Deprecated functions */
433 +gboolean gnome_vfs_ace_get_negative (GnomeVFSACE *entry);
434 +void gnome_vfs_ace_set_negative (GnomeVFSACE *entry,
435 + gboolean negative);
437 G_END_DECLS
439 --- gnome-vfs-2.17.2-orig/libgnomevfs/gnome-vfs-acl.c 2007-04-10 01:50:02.414684000 +0200
440 +++ gnome-vfs-2.17.2-alo/libgnomevfs/gnome-vfs-acl.c 2007-04-03 12:35:46.112022000 +0200
441 @@ -37,6 +37,7 @@
442 struct _GnomeVFSACLPrivate {
443 GList *entries;
444 gboolean modified;
445 + GnomeVFSACLScheme scheme;
448 static void
449 @@ -236,7 +237,6 @@
450 GList *list;
452 priv = acl->priv;
454 list = g_list_copy (priv->entries);
456 g_list_foreach (list, (GFunc) g_object_ref, NULL);
457 @@ -282,7 +282,23 @@
458 case GNOME_VFS_ACL_OTHER:
459 value = "other";
460 break;
463 + case GNOME_VFS_ACL_MASK:
464 + value = "mask";
465 + break;
467 + case GNOME_VFS_ACL_EVERYONE:
468 + value = "everyone";
469 + break;
471 + case GNOME_VFS_ACL_OWNER_USER:
472 + value = "owner user";
473 + break;
475 + case GNOME_VFS_ACL_OWNER_GROUP:
476 + value = "owner group";
477 + break;
479 default:
480 value = "unknown";
481 break;
482 @@ -314,6 +330,64 @@
483 case GNOME_VFS_ACL_EXECUTE:
484 value = "execute";
485 break;
487 + /* NFSv4, ZFS extended permissions
488 + */
489 + case GNOME_VFS_ACL_LIST_DIRECTORY:
490 + value = "list directory";
491 + break;
493 + GNOME_VFS_ACL_ADD_FILE:
494 + value = "add file";
495 + break;
497 + GNOME_VFS_ACL_APPEND_DATA:
498 + value = "append data";
499 + break;
501 + GNOME_VFS_ACL_ADD_SUBDIRECTORY:
502 + value = "add subdirectory";
503 + break;
505 + GNOME_VFS_ACL_READ_NAMED_ATTRS:
506 + value = "read named attributes";
507 + break;
509 + GNOME_VFS_ACL_WRITE_NAMED_ATTRS:
510 + value = "write named attributes";
511 + break;
513 + GNOME_VFS_ACL_DELETE_CHILD:
514 + value = "delete child";
515 + break;
517 + GNOME_VFS_ACL_READ_ATTRIBUTES:
518 + value = "read attributes";
519 + break;
521 + GNOME_VFS_ACL_WRITE_ATTRIBUTES:
522 + value = "write attributes";
523 + break;
525 + GNOME_VFS_ACL_DELETE:
526 + value = "delete";
527 + break;
529 + GNOME_VFS_ACL_READ_ACL:
530 + value = "read acl";
531 + break;
533 + GNOME_VFS_ACL_WRITE_ACL:
534 + value = "write acl";
535 + break;
537 + GNOME_VFS_ACL_WRITE_OWNER:
538 + value = "write owner";
539 + break;
541 + GNOME_VFS_ACL_SYNCHRONIZE:
542 + value = "synchronize";
543 + break;
545 default:
546 value = "unknown";
547 @@ -326,3 +400,88 @@
548 return value;
552 +const char *
553 +gnome_vfs_acl_type_to_string (GnomeVFSACLType type)
555 + const char *value;
557 + if (type < GNOME_VFS_ACL_TYPE_SYS_LAST) {
559 + switch (type) {
560 + case GNOME_VFS_ACL_ALLOW:
561 + value = "allow";
562 + break;
564 + case GNOME_VFS_ACL_DENY:
565 + value = "deny";
566 + break;
568 + case GNOME_VFS_ACL_AUDIT:
569 + value = "audit";
570 + break;
572 + case GNOME_VFS_ACL_ALARM:
573 + value = "alarm";
574 + break;
576 + default:
577 + value = "unknown";
578 + break;
581 + } else {
582 + value = "unknown";
584 + return value;
588 +const char *
589 +gnome_vfs_acl_inherance_to_string (GnomeVFSACLInherance inheritance)
591 + const char *value;
593 + if (inheritance < GNOME_VFS_ACL_TYPE_SYS_LAST) {
595 + switch (inheritance) {
596 + case GNOME_VFS_ACL_FILE_INHERIT:
597 + value = "File inherit";
598 + break;
600 + case GNOME_VFS_ACL_DIR_INHERIT:
601 + value = "Directory inherit";
602 + break;
604 + case GNOME_VFS_ACL_INHERIT_ONLY:
605 + value = "Inherit only";
606 + break;
608 + case GNOME_VFS_ACL_NO_PROPAGATE:
609 + value = "No propagate";
610 + break;
612 + default:
613 + value = "unknown";
614 + break;
616 + } else {
617 + value = "unknown";
619 + return value;
623 +void
624 +gnome_vfs_acl_set_scheme (GnomeVFSACL *acl,
625 + GnomeVFSACLScheme scheme)
627 + acl->priv->scheme = scheme;
631 +GnomeVFSACLScheme
632 +gnome_vfs_acl_get_scheme (GnomeVFSACL *acl)
634 + return acl->priv->scheme;
636 --- gnome-vfs-2.17.2-orig/libgnomevfs/gnome-vfs-acl.h 2007-04-10 01:50:02.395830000 +0200
637 +++ gnome-vfs-2.17.2-alo/libgnomevfs/gnome-vfs-acl.h 2007-04-10 00:59:28.459819000 +0200
638 @@ -35,16 +35,39 @@
640 /* ************************************************************************** */
642 +/* ACL Audience */
644 +const char * gnome_vfs_acl_inherance_to_string (GnomeVFSACLInherance inherance);
646 +enum {
647 + GNOME_VFS_ACL_INHERANCE_NULL = 0,
648 + GNOME_VFS_ACL_FILE_INHERIT,
649 + GNOME_VFS_ACL_DIR_INHERIT,
650 + GNOME_VFS_ACL_INHERIT_ONLY,
651 + GNOME_VFS_ACL_NO_PROPAGATE,
652 + GNOME_VFS_ACL_INHERANCE_SYS_LAST
656 /* ACL Kinds */
658 const char * gnome_vfs_acl_kind_to_string (GnomeVFSACLKind kind);
660 enum {
661 GNOME_VFS_ACL_KIND_NULL = 0,
663 + /* Basic kinds */
664 GNOME_VFS_ACL_USER,
665 GNOME_VFS_ACL_GROUP,
666 GNOME_VFS_ACL_OTHER,
667 GNOME_VFS_ACL_MASK,
670 + /* NFSv4, ZFS extended kinds */
671 + GNOME_VFS_ACL_EVERYONE,
672 + GNOME_VFS_ACL_OWNER_USER,
673 + GNOME_VFS_ACL_OWNER_GROUP,
675 GNOME_VFS_ACL_KIND_SYS_LAST
678 @@ -54,13 +77,52 @@
680 enum {
681 GNOME_VFS_ACL_PERM_NULL = 0,
683 + /* Basic permissions */
684 GNOME_VFS_ACL_READ = 1,
685 GNOME_VFS_ACL_WRITE,
686 - GNOME_VFS_ACL_EXECUTE,
687 + GNOME_VFS_ACL_EXECUTE,
689 + /* NFSv4, ZFS extended permissions */
690 + GNOME_VFS_ACL_LIST_DIRECTORY,
691 + GNOME_VFS_ACL_ADD_FILE,
692 + GNOME_VFS_ACL_APPEND_DATA,
693 + GNOME_VFS_ACL_ADD_SUBDIRECTORY,
694 + GNOME_VFS_ACL_READ_NAMED_ATTRS,
695 + GNOME_VFS_ACL_WRITE_NAMED_ATTRS,
696 + GNOME_VFS_ACL_DELETE_CHILD,
697 + GNOME_VFS_ACL_READ_ATTRIBUTES,
698 + GNOME_VFS_ACL_WRITE_ATTRIBUTES,
699 + GNOME_VFS_ACL_DELETE,
700 + GNOME_VFS_ACL_READ_ACL,
701 + GNOME_VFS_ACL_WRITE_ACL,
702 + GNOME_VFS_ACL_WRITE_OWNER,
703 + GNOME_VFS_ACL_SYNCHRONIZE,
705 GNOME_VFS_ACL_PERM_SYS_LAST
709 +/* ACL types */
711 +const char * gnome_vfs_acl_type_to_string (GnomeVFSACLType type);
713 +enum {
714 + GNOME_VFS_ACL_TYPE_NULL = 0,
715 + GNOME_VFS_ACL_ALLOW,
716 + GNOME_VFS_ACL_DENY,
717 + GNOME_VFS_ACL_AUDIT,
718 + GNOME_VFS_ACL_ALARM,
719 + GNOME_VFS_ACL_TYPE_SYS_LAST
722 +/* ACL scheme */
723 +enum {
724 + GNOME_VFS_ACL_SCHEME_NULL,
725 + GNOME_VFS_ACL_SCHEME_CLASSIC,
726 + GNOME_VFS_ACL_SCHEME_NFS4
729 /* ************************************************************************** */
731 #define GNOME_VFS_TYPE_ACL (gnome_vfs_acl_get_type ())
732 @@ -97,6 +159,11 @@
733 GList * gnome_vfs_acl_get_ace_list (GnomeVFSACL *acl);
734 void gnome_vfs_acl_free_ace_list (GList *ace_list);
736 +void gnome_vfs_acl_set_scheme (GnomeVFSACL *acl,
737 + GnomeVFSACLScheme scheme);
738 +GnomeVFSACLScheme
739 + gnome_vfs_acl_get_scheme (GnomeVFSACL *acl);
741 G_END_DECLS
744 --- gnome-vfs-2.17.2-orig/modules/file-method-acl.c 2007-04-10 01:50:02.776935000 +0200
745 +++ gnome-vfs-2.17.2-alo/modules/file-method-acl.c 2007-04-10 01:17:48.169875000 +0200
746 @@ -34,9 +34,7 @@
747 #include <unistd.h>
748 #include <stdlib.h>
749 #include <sys/types.h>
750 -#ifdef HAVE_SYS_RESOURCE_H
751 #include <sys/resource.h>
752 -#endif
754 #ifdef HAVE_PWD_H
755 # include <pwd.h>
756 @@ -74,8 +72,7 @@
757 struct passwd *pw = NULL;
758 gpointer buffer = NULL;
759 gint error;
761 -#if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
762 +// #if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
763 struct passwd pwd;
764 glong bufsize;
766 @@ -84,7 +81,6 @@
767 #else
768 bufsize = 64;
769 #endif /* _SC_GETPW_R_SIZE_MAX */
772 do {
773 g_free (buffer);
774 @@ -94,7 +90,7 @@
775 errno = 0;
777 #ifdef HAVE_POSIX_GETPWUID_R
778 - error = getpwuid_r (uid, &pwd, buffer, bufsize, &pw);
779 + error = getpwuid_r (uid, &pwd, buffer, bufsize, &pw);
780 error = error < 0 ? errno : error;
781 #else /* HAVE_NONPOSIX_GETPWUID_R */
782 /* HPUX 11 falls into the HAVE_POSIX_GETPWUID_R case */
783 @@ -102,11 +98,10 @@
784 error = getpwuid_r (uid, &pwd, buffer, bufsize);
785 pw = error == 0 ? &pwd : NULL;
786 #else /* !_AIX */
787 - pw = getpwuid_r (uid, &pwd, buffer, bufsize);
788 + pw = getpwuid_r (uid, &pwd, buffer, bufsize, &pw);
789 error = pw ? 0 : errno;
790 #endif /* !_AIX */
791 #endif /* HAVE_NONPOSIX_GETPWUID_R */
793 if (pw == NULL) {
794 if (error == 0 || error == ENOENT) {
795 break;
796 @@ -120,7 +115,7 @@
797 bufsize *= 2;
799 } while (pw == NULL);
800 -#endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
801 +// #endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
803 if (pw == NULL) {
804 setpwent ();
805 @@ -133,7 +128,6 @@
808 #endif /* HAVE_PWD_H */
810 if (uid_string == NULL) {
811 uid_string = g_strdup_printf ("%d", uid);
813 @@ -399,7 +393,7 @@
816 permset_to_perms (e_ps, pset);
817 - ace = gnome_vfs_ace_new (kind, id, pset);
818 + ace = gnome_vfs_ace_new (kind, id, pset, GNOME_VFS_ACL_ALLOW);
820 g_free (id);
822 @@ -427,7 +421,8 @@
823 /* SOLARIS ACL */
825 #ifdef HAVE_SOLARIS_ACL
826 -#define SOLARIS_N_TAGS 3
827 +//#define SOLARIS_N_TAGS 3
828 +#define SOLARIS_N_TAGS GNOME_VFS_ACL_PERM_SYS_LAST
830 static gboolean
831 fixup_acl (GnomeVFSACL *acl, GSList *acls)
832 @@ -448,7 +443,9 @@
833 GnomeVFSACLKind kind;
834 GnomeVFSACE *ace = GNOME_VFS_ACE(i->data);
836 - if (!gnome_vfs_ace_get_inherit(ace))
837 +// if (!gnome_vfs_ace_get_inherit(ace))
838 +// continue;
839 + if (gnome_vfs_ace_get_inherance(ace) == GNOME_VFS_ACL_INHERANCE_NULL)
840 continue;
842 defaults = TRUE;
843 @@ -492,8 +489,8 @@
844 GNOME_VFS_ACL_WRITE,
845 GNOME_VFS_ACL_EXECUTE, 0};
847 - ace = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, NULL, perms);
848 - gnome_vfs_ace_set_inherit (ace, TRUE);
849 + ace = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, NULL, perms, GNOME_VFS_ACL_ALLOW, GNOME_VFS_ACL_FILE_INHERIT);
850 +// gnome_vfs_ace_set_inherit (ace, TRUE);
851 gnome_vfs_acl_set (acl, ace);
852 g_slist_append(acls, ace);
854 @@ -504,8 +501,8 @@
855 GnomeVFSACE *ace;
856 GnomeVFSACLPerm perms[] = {0};
858 - ace = gnome_vfs_ace_new (GNOME_VFS_ACL_GROUP, NULL, perms);
859 - gnome_vfs_ace_set_inherit (ace, TRUE);
860 + ace = gnome_vfs_ace_new (GNOME_VFS_ACL_GROUP, NULL, perms, GNOME_VFS_ACL_ALLOW, GNOME_VFS_ACL_FILE_INHERIT);
861 +// gnome_vfs_ace_set_inherit (ace, TRUE);
862 gnome_vfs_acl_set (acl, ace);
864 changed = TRUE;
865 @@ -515,8 +512,8 @@
866 GnomeVFSACE *ace;
867 GnomeVFSACLPerm perms[] = {0};
869 - ace = gnome_vfs_ace_new (GNOME_VFS_ACL_OTHER, NULL, perms);
870 - gnome_vfs_ace_set_inherit (ace, TRUE);
871 + ace = gnome_vfs_ace_new (GNOME_VFS_ACL_OTHER, NULL, perms, GNOME_VFS_ACL_ALLOW, GNOME_VFS_ACL_FILE_INHERIT);
872 +// gnome_vfs_ace_set_inherit (ace, TRUE);
873 gnome_vfs_acl_set (acl, ace);
875 changed = TRUE;
876 @@ -528,8 +525,8 @@
877 GNOME_VFS_ACL_WRITE,
878 GNOME_VFS_ACL_EXECUTE, 0};
880 - ace = gnome_vfs_ace_new (GNOME_VFS_ACL_MASK, NULL, perms);
881 - gnome_vfs_ace_set_inherit (ace, TRUE);
882 + ace = gnome_vfs_ace_new (GNOME_VFS_ACL_MASK, NULL, perms, GNOME_VFS_ACL_ALLOW, GNOME_VFS_ACL_FILE_INHERIT);
883 +// gnome_vfs_ace_set_inherit (ace, TRUE);
884 gnome_vfs_acl_set (acl, ace);
886 changed = TRUE;
887 @@ -564,6 +561,76 @@
888 return i;
892 +static int
893 +nfs4_access_mask_to_perms (int access_mask, GnomeVFSACLPerm *tags)
895 + int i;
897 + memset (tags, 0, sizeof (GnomeVFSACLPerm) * (SOLARIS_N_TAGS + 1));
898 + i = 0;
900 + /* Basic permissions
901 + */
902 + if (access_mask & ACE_READ_DATA)
903 + tags[i++] = GNOME_VFS_ACL_READ;
905 + if (access_mask & ACE_WRITE_DATA)
906 + tags[i++] = GNOME_VFS_ACL_WRITE;
908 + if (access_mask & ACE_EXECUTE)
909 + tags[i++] = GNOME_VFS_ACL_EXECUTE;
911 + /* NFS4 permissions
912 + */
913 + if (access_mask & ACE_LIST_DIRECTORY)
914 + tags[i++] = GNOME_VFS_ACL_LIST_DIRECTORY;
916 + if (access_mask & ACE_ADD_FILE)
917 + tags[i++] = GNOME_VFS_ACL_ADD_FILE;
919 + if (access_mask & ACE_APPEND_DATA)
920 + tags[i++] = GNOME_VFS_ACL_APPEND_DATA;
922 + if (access_mask & ACE_ADD_SUBDIRECTORY)
923 + tags[i++] = GNOME_VFS_ACL_ADD_SUBDIRECTORY;
925 + if (access_mask & ACE_READ_NAMED_ATTRS)
926 + tags[i++] = GNOME_VFS_ACL_READ_NAMED_ATTRS;
928 + if (access_mask & ACE_WRITE_NAMED_ATTRS)
929 + tags[i++] = GNOME_VFS_ACL_WRITE_NAMED_ATTRS;
931 + if (access_mask & ACE_DELETE_CHILD)
932 + tags[i++] = GNOME_VFS_ACL_DELETE_CHILD;
934 + if (access_mask & ACE_READ_ATTRIBUTES)
935 + tags[i++] = GNOME_VFS_ACL_READ_ATTRIBUTES;
937 + if (access_mask & ACE_WRITE_ATTRIBUTES)
938 + tags[i++] = GNOME_VFS_ACL_WRITE_ATTRIBUTES;
940 + if (access_mask & ACE_DELETE)
941 + tags[i++] = GNOME_VFS_ACL_DELETE;
943 + if (access_mask & ACE_READ_ACL)
944 + tags[i++] = GNOME_VFS_ACL_READ_ACL;
946 + if (access_mask & ACE_WRITE_ACL)
947 + tags[i++] = GNOME_VFS_ACL_WRITE_ACL;
949 + if (access_mask & ACE_WRITE_OWNER)
950 + tags[i++] = GNOME_VFS_ACL_WRITE_OWNER;
952 + if (access_mask & ACE_SYNCHRONIZE)
953 + tags[i++] = GNOME_VFS_ACL_SYNCHRONIZE;
955 + return i;
961 static int
962 solaris_acl_read (GnomeVFSACL *acl,
963 aclent_t *aclp,
964 @@ -574,10 +641,11 @@
965 aclent_t *tp;
967 for (tp = aclp, i=0; i < aclcnt; tp++, i++) {
968 - GnomeVFSACE *ace;
969 - GnomeVFSACLKind kind;
970 - GnomeVFSACLPerm pset[SOLARIS_N_TAGS+1];
971 - char *id;
972 + GnomeVFSACE *ace;
973 + GnomeVFSACLKind kind;
974 + GnomeVFSACLInherance inherance;
975 + GnomeVFSACLPerm pset[SOLARIS_N_TAGS+1];
976 + char *id;
978 id = NULL;
979 kind = GNOME_VFS_ACL_KIND_NULL;
980 @@ -613,11 +681,13 @@
981 g_warning ("Unhandled Solaris ACE: %d\n", tp->a_type);
984 - permset_to_perms (tp->a_perm, pset);
985 - ace = gnome_vfs_ace_new (kind, id, pset);
986 +// if (tp->a_type & ACL_DEFAULT)
987 +// gnome_vfs_ace_set_inherit (ace, TRUE);
989 + inherance = (tp->a_type & ACL_DEFAULT) ? GNOME_VFS_ACL_FILE_INHERIT : GNOME_VFS_ACL_INHERANCE_NULL;
991 - if (tp->a_type & ACL_DEFAULT)
992 - gnome_vfs_ace_set_inherit (ace, TRUE);
993 + permset_to_perms (tp->a_perm, pset);
994 + ace = gnome_vfs_ace_new (kind, id, pset, GNOME_VFS_ACL_ALLOW, inherance);
996 gnome_vfs_acl_set (acl, ace);
997 g_object_unref (ace);
998 @@ -626,6 +696,88 @@
999 return 0;
1002 +static int
1003 +solaris_acl_nfs4_read (GnomeVFSACL *acl,
1004 + ace_t *aclp,
1005 + int aclcnt,
1006 + gboolean def)
1008 + int i;
1009 + ace_t *tp;
1011 + for (tp = aclp, i=0; i < aclcnt; tp++, i++) {
1012 + GnomeVFSACE *ace;
1013 + GnomeVFSACLKind kind;
1014 + GnomeVFSACLInherance inherance;
1015 + GnomeVFSACLPerm pset[SOLARIS_N_TAGS+1];
1016 + char *id;
1017 + int owner_type;
1018 + int type;
1020 + id = NULL;
1021 + type = GNOME_VFS_ACL_TYPE_NULL;
1022 + kind = GNOME_VFS_ACL_KIND_NULL;
1023 + inherance = GNOME_VFS_ACL_INHERANCE_NULL;
1024 + owner_type = tp->a_flags & ACE_TYPE_FLAGS;
1026 + /* Type: allow, deny, ..
1027 + */
1028 + switch (tp->a_type) {
1029 + case ACE_ACCESS_ALLOWED_ACE_TYPE:
1030 + type = GNOME_VFS_ACL_ALLOW;
1031 + break;
1032 + case ACE_ACCESS_DENIED_ACE_TYPE:
1033 + type = GNOME_VFS_ACL_DENY;
1034 + break;
1035 + default:
1036 + type = GNOME_VFS_ACL_TYPE_NULL;
1039 + /* Kind: user, group, everyone, ..
1040 + */
1041 + if (owner_type == ACE_OWNER) {
1042 + kind = GNOME_VFS_ACL_OWNER_USER;
1044 + } else if (owner_type == (ACE_GROUP|ACE_IDENTIFIER_GROUP)) {
1045 + kind = GNOME_VFS_ACL_OWNER_GROUP;
1047 + } else if (owner_type == ACE_GROUP) {
1048 + if (tp->a_who >= 0)
1049 + id = gid_to_string (tp->a_who);
1050 + kind = GNOME_VFS_ACL_GROUP;
1052 + } else if (owner_type == ACE_EVERYONE) {
1053 + kind = GNOME_VFS_ACL_EVERYONE;
1055 + } else {
1056 + if (tp->a_who >= 0)
1057 + id = uid_to_string (tp->a_who);
1058 + kind = GNOME_VFS_ACL_USER;
1059 + }
1061 + /* Inherance
1062 + */
1063 + if (tp->a_flags & ACE_FILE_INHERIT_ACE) {
1064 + inherance = GNOME_VFS_ACL_FILE_INHERIT;
1065 + } else if (tp->a_flags & ACE_DIRECTORY_INHERIT_ACE) {
1066 + inherance = GNOME_VFS_ACL_DIR_INHERIT;
1067 + } else if (tp->a_flags & ACE_NO_PROPAGATE_INHERIT_ACE) {
1068 + inherance = GNOME_VFS_ACL_NO_PROPAGATE;
1069 + } else if (tp->a_flags & ACE_INHERIT_ONLY_ACE) {
1070 + inherance = GNOME_VFS_ACL_INHERIT_ONLY;
1071 + }
1073 + /* Permissions
1074 + */
1075 + nfs4_access_mask_to_perms (tp->a_access_mask, pset);
1077 + ace = gnome_vfs_ace_new (kind, id, pset, type, inherance);
1078 + gnome_vfs_acl_set (acl, ace);
1080 + g_object_unref (ace);
1084 static GnomeVFSResult
1085 translate_ace_into_aclent (GnomeVFSACE *ace, aclent_t *aclp)
1087 @@ -637,7 +789,7 @@
1089 id_str = gnome_vfs_ace_get_id (ace);
1090 kind = gnome_vfs_ace_get_kind (ace);
1091 - is_default = gnome_vfs_ace_get_inherit (ace);
1092 + is_default = (gnome_vfs_ace_get_inherance(ace) != GNOME_VFS_ACL_INHERANCE_NULL);
1094 aclp->a_perm = 0;
1095 aclp->a_id = 0;
1096 @@ -725,22 +877,18 @@
1098 #endif /* HAVE_ACL */
1100 -GnomeVFSResult file_get_acl (const char *path,
1101 - GnomeVFSFileInfo *info,
1102 - struct stat *statbuf,
1103 - GnomeVFSContext *context)
1106 #ifdef HAVE_SOLARIS_ACL
1107 +GnomeVFSResult
1108 +file_get_acl_classic (const char *path,
1109 + GnomeVFSFileInfo *info,
1110 + struct stat *statbuf,
1111 + GnomeVFSContext *context)
1113 int re;
1114 int aclcnt;
1115 aclent_t *aclp;
1117 - if (info->acl != NULL) {
1118 - gnome_vfs_acl_clear (info->acl);
1119 - } else {
1120 - info->acl = gnome_vfs_acl_new ();
1123 aclcnt = acl (path, GETACLCNT, 0, NULL);
1124 if (aclcnt < 0) {
1125 return aclerrno_to_vfserror (errno);
1126 @@ -768,9 +916,84 @@
1128 info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ACL;
1130 - free (aclp);
1132 + free (aclp);
1133 return GNOME_VFS_OK;
1137 +GnomeVFSResult
1138 +file_get_acl_nfs4 (const char *path,
1139 + GnomeVFSFileInfo *info,
1140 + struct stat *statbuf,
1141 + GnomeVFSContext *context)
1143 + int re;
1144 + int aclcnt;
1145 + ace_t *aclp;
1147 + aclcnt = acl (path, ACE_GETACLCNT, 0, NULL);
1148 + if (aclcnt < 0) {
1149 + return aclerrno_to_vfserror (errno);
1152 + if (aclcnt < MIN_ACL_ENTRIES) {
1153 + return GNOME_VFS_ERROR_INTERNAL;
1156 + aclp = (ace_t *)malloc(sizeof (ace_t) * aclcnt);
1157 + if (aclp == NULL) {
1158 + return GNOME_VFS_ERROR_NO_MEMORY;
1161 + errno = 0;
1162 + re = acl (path, ACE_GETACL, aclcnt, aclp);
1163 + if (re < 0) {
1164 + return aclerrno_to_vfserror (errno);
1167 + re = solaris_acl_nfs4_read (info->acl, aclp, aclcnt, FALSE);
1168 + if (re < 0) {
1169 + return GNOME_VFS_ERROR_INTERNAL;
1172 + info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ACL;
1174 + free (aclp);
1175 + return GNOME_VFS_OK;
1177 +#endif
1180 +GnomeVFSResult file_get_acl (const char *path,
1181 + GnomeVFSFileInfo *info,
1182 + struct stat *statbuf,
1183 + GnomeVFSContext *context)
1185 +#ifdef HAVE_SOLARIS_ACL
1186 + long acl_type;
1188 + if (info->acl != NULL) {
1189 + gnome_vfs_acl_clear (info->acl);
1190 + } else {
1191 + info->acl = gnome_vfs_acl_new ();
1194 + /* Check the ACL type
1195 + */
1196 + acl_type = pathconf (path, _PC_ACL_ENABLED);
1198 + /* Call the sub-handler
1199 + */
1200 + if (acl_type == _ACL_ACLENT_ENABLED) {
1201 + gnome_vfs_acl_set_scheme (info->acl, GNOME_VFS_ACL_SCHEME_CLASSIC);
1202 + return file_get_acl_classic (path, info, statbuf, context);
1203 + }
1204 + else if (acl_type == _ACL_ACE_ENABLED) {
1205 + gnome_vfs_acl_set_scheme (info->acl, GNOME_VFS_ACL_SCHEME_NFS4);
1206 + return file_get_acl_nfs4 (path, info, statbuf, context);
1209 + return GNOME_VFS_ERROR_GENERIC;
1211 #elif defined(HAVE_POSIX_ACL)
1212 acl_t p_acl;
1213 @@ -813,10 +1036,11 @@
1218 GnomeVFSResult
1219 -file_set_acl (const char *path,
1220 - const GnomeVFSFileInfo *info,
1221 - GnomeVFSContext *context)
1222 +file_set_acl_classic (const char *path,
1223 + const GnomeVFSFileInfo *info,
1224 + GnomeVFSContext *context)
1226 #ifdef HAVE_SOLARIS_ACL
1227 GList *acls;
1228 @@ -828,8 +1052,6 @@
1229 guint aclp_i;
1230 gboolean changed;
1232 - if (info->acl == NULL)
1233 - return GNOME_VFS_ERROR_BAD_PARAMETERS;
1235 acls = gnome_vfs_acl_get_ace_list (info->acl);
1236 if (acls == NULL) return GNOME_VFS_OK;
1237 @@ -880,6 +1102,8 @@
1240 g_free (new_aclp);
1241 + gnome_vfs_acl_free_ace_list (acls);
1243 return GNOME_VFS_OK;
1245 #elif defined(HAVE_POSIX_ACL)
1246 @@ -1014,4 +1238,414 @@
1247 #endif
1250 +static GnomeVFSResult
1251 +translate_ace_into_nfs4_ace (GnomeVFSACE *ace,
1252 + ace_t *system_ace)
1254 + const char *id;
1255 + GnomeVFSACLKind kind;
1256 + GnomeVFSACLType type;
1257 + GnomeVFSACLInherance inherance;
1259 + g_assert (GNOME_VFS_IS_ACE(ace));
1261 + id = gnome_vfs_ace_get_id (ace);
1262 + kind = gnome_vfs_ace_get_kind (ace);
1263 + type = gnome_vfs_ace_get_ace_type (ace);
1264 + inherance = gnome_vfs_ace_get_inherance (ace);
1266 + /* Set the ID
1267 + */
1268 + system_ace->a_who = -1;
1269 + if (id) {
1270 + gint num;
1271 + num = string_to_uid(id);
1272 + if (num >= 0) {
1273 + system_ace->a_who = num;
1277 + /* Set the type
1278 + */
1279 + if (type == GNOME_VFS_ACL_DENY)
1280 + system_ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
1281 + else
1282 + system_ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
1284 + /* Set the kind
1285 + */
1286 + switch (kind) {
1287 + case GNOME_VFS_ACL_USER:
1288 + system_ace->a_flags = 0;
1289 + break;
1290 + case GNOME_VFS_ACL_GROUP:
1291 + system_ace->a_flags |= ACE_IDENTIFIER_GROUP;
1292 + break;
1294 + case GNOME_VFS_ACL_OWNER_USER:
1295 + system_ace->a_flags |= ACE_OWNER;
1296 + break;
1297 + case GNOME_VFS_ACL_OWNER_GROUP:
1298 + system_ace->a_flags |= (ACE_GROUP | ACE_IDENTIFIER_GROUP);
1299 + break;
1301 + case GNOME_VFS_ACL_EVERYONE:
1302 + system_ace->a_flags |= ACE_EVERYONE;
1303 + break;
1306 + /* Permissions
1307 + */
1308 +#define set_perm(gnome,system) \
1309 + do { \
1310 + if (gnome_vfs_ace_check_perm (ace, gnome)) \
1311 + system_ace->a_access_mask |= system; \
1312 + else \
1313 + system_ace->a_access_mask &= ~system; \
1314 + } while(0)
1316 + set_perm (GNOME_VFS_ACL_READ, ACE_READ_DATA);
1317 + set_perm (GNOME_VFS_ACL_WRITE, ACE_WRITE_DATA);
1318 + set_perm (GNOME_VFS_ACL_EXECUTE, ACE_EXECUTE);
1320 + set_perm (GNOME_VFS_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY);
1321 + set_perm (GNOME_VFS_ACL_ADD_FILE, ACE_ADD_FILE);
1322 + set_perm (GNOME_VFS_ACL_APPEND_DATA, ACE_APPEND_DATA);
1323 + set_perm (GNOME_VFS_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY);
1324 + set_perm (GNOME_VFS_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS);
1325 + set_perm (GNOME_VFS_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS);
1326 + set_perm (GNOME_VFS_ACL_DELETE_CHILD, ACE_DELETE_CHILD);
1327 + set_perm (GNOME_VFS_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES);
1328 + set_perm (GNOME_VFS_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES);
1329 + set_perm (GNOME_VFS_ACL_DELETE, ACE_DELETE);
1330 + set_perm (GNOME_VFS_ACL_READ_ACL, ACE_READ_ACL);
1331 + set_perm (GNOME_VFS_ACL_WRITE_ACL, ACE_WRITE_ACL);
1332 + set_perm (GNOME_VFS_ACL_WRITE_OWNER, ACE_WRITE_OWNER);
1333 + set_perm (GNOME_VFS_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE);
1334 +#undef set_perm
1336 + /* Inherance
1337 + */
1338 + switch (inherance) {
1339 + case GNOME_VFS_ACL_FILE_INHERIT:
1340 + system_ace->a_flags &= ACE_FILE_INHERIT_ACE;
1341 + break;
1342 + case GNOME_VFS_ACL_DIR_INHERIT:
1343 + system_ace->a_flags &= ACE_DIRECTORY_INHERIT_ACE;
1344 + break;
1345 + case GNOME_VFS_ACL_NO_PROPAGATE:
1346 + system_ace->a_flags &= ACE_NO_PROPAGATE_INHERIT_ACE;
1347 + break;
1348 + case GNOME_VFS_ACL_INHERIT_ONLY:
1349 + system_ace->a_flags &= ACE_INHERIT_ONLY_ACE;
1350 + break;
1353 + return GNOME_VFS_OK;
1357 +GnomeVFSResult
1358 +file_set_acl_nfs4 (const char *path,
1359 + const GnomeVFSFileInfo *info,
1360 + GnomeVFSContext *context)
1362 + GList *acls;
1363 + guint len;
1364 + GList *entry;
1365 + ace_t *new_aclp;
1366 + ace_t *taclp;
1367 + guint aclp_i;
1368 + guint re;
1370 + acls = gnome_vfs_acl_get_ace_list (info->acl);
1371 + if (acls == NULL) return GNOME_VFS_OK;
1373 + // fix acls??
1375 + len = g_list_length (acls);
1376 + if (len <= 0) return GNOME_VFS_OK;
1378 + acls = g_list_reverse (acls);
1380 + new_aclp = (ace_t *) malloc (len * sizeof(ace_t));
1381 + if (new_aclp == NULL) return GNOME_VFS_ERROR_NO_MEMORY;
1382 + memset (new_aclp, 0, len * sizeof(ace_t));
1384 + /* Convert GNOME-VFS aces to system ace_t's
1385 + */
1386 + aclp_i = 0;
1387 + taclp = new_aclp;
1388 + for (entry=acls; entry != NULL; entry = entry->next) {
1389 + GnomeVFSACE *ace = GNOME_VFS_ACE(entry->data);
1391 + re = translate_ace_into_nfs4_ace (ace, taclp);
1392 + if (re != GNOME_VFS_OK) continue;
1394 + aclp_i++;
1395 + taclp++;
1396 + }
1398 + /* Commit it to the file system
1399 + */
1400 + re = acl (path, ACE_SETACL, aclp_i, (ace_t *)new_aclp);
1401 + if (re < 0) {
1402 + int err = errno;
1404 + g_free (new_aclp);
1405 + return aclerrno_to_vfserror(err);
1408 + g_free (new_aclp);
1409 + gnome_vfs_acl_free_ace_list (acls);
1411 + return GNOME_VFS_OK;
1414 +GnomeVFSResult
1415 +file_set_acl (const char *path,
1416 + const GnomeVFSFileInfo *info,
1417 + GnomeVFSContext *context)
1419 + GnomeVFSACLScheme scheme;
1421 + if (info->acl == NULL)
1422 + return GNOME_VFS_ERROR_BAD_PARAMETERS;
1424 + scheme = gnome_vfs_acl_get_scheme(info->acl);
1425 + if (scheme == GNOME_VFS_ACL_SCHEME_CLASSIC)
1426 + return file_set_acl_classic (path, info, context);
1428 + return file_set_acl_nfs4 (path, info, context);
1435 +#ifndef HAVE_GETPWNAM_R
1436 +G_LOCK_DEFINE (getpwnam_lock);
1437 +#endif
1439 +static int
1440 +secure_getpwnam (const char *name, struct passwd *pwbuf, char *buf, size_t buflen)
1442 +#ifndef HAVE_GETPWNAM_R
1443 + size_t pw_name_len = 0;
1444 + size_t pw_passwd_len = 0;
1445 + size_t pw_gecos_len = 0;
1446 + size_t pw_dir_len = 0;
1447 + size_t pw_shell_len = 0;
1448 + char *ptr;
1449 + struct passwd *tmp;
1451 + G_LOCK(getpwnam_lock);
1453 + tmp = getpwnam (name);
1454 + if (tmp == NULL)
1455 + return errno;
1457 + if (tmp->pw_name) pw_name_len = strlen(tmp->pw_name);
1458 + if (tmp->pw_passwd) pw_passwd_len = strlen(tmp->pw_passwd);
1459 + if (tmp->pw_gecos) pw_gecos_len = strlen(tmp->pw_gecos);
1460 + if (tmp->pw_dir) pw_dir_len = strlen(tmp->pw_dir);
1461 + if (tmp->pw_shell) pw_shell_len = strlen(tmp->pw_shell);
1463 + if ((pw_name_len + pw_passwd_len +
1464 + pw_gecos_len + pw_dir_len + pw_shell_len) > buflen)
1465 + return ERANGE;
1467 + memset (buf, 0, buflen);
1468 + ptr = buf;
1472 + if (tmp->pw_name) {
1473 + memcpy (ptr, tmp->pw_name, pw_name_len);
1474 + pwbuf->pw_name = ptr;
1475 + ptr += pw_name_len + 1;
1478 + if (tmp->pw_passwd) {
1479 + memcpy (ptr, tmp->pw_passwd, pw_passwd_len);
1480 + pwbuf->pw_passwd = ptr;
1481 + ptr += pw_passwd_len + 1;
1484 + if (tmp->pw_gecos) {
1485 + memcpy (ptr, tmp->pw_gecos, pw_gecos_len);
1486 + pwbuf->pw_gecos = ptr;
1487 + ptr += pw_gecos_len + 1;
1490 + if (tmp->pw_dir) {
1491 + memcpy (ptr, tmp->pw_dir, pw_dir_len);
1492 + pwbuf->pw_dir = ptr;
1493 + ptr += pw_dir_len + 1;
1496 + if (tmp->pw_shell) {
1497 + memcpy (ptr, tmp->pw_shell, pw_shell_len);
1498 + pwbuf->pw_shell = ptr;
1499 + ptr += pw_shell_len + 1;
1502 + G_UNLOCK(getpwnam_lock);
1503 + return 0;
1505 +#elif HAVE_GETPWNAM_R_5
1506 + struct passwd *tmp;
1508 + return getpwnam_r (name, pwbuf, buf, buflen, &tmp);
1510 +#elif HAVE_GETPWNAM_R_4
1512 + return getpwnam_r (name, pwbuf, buf, buflen);
1513 +#endif
1515 + return 0;
1521 +#ifndef HAVE_GETGRNAM_R
1522 +G_LOCK_DEFINE (getgrnam_lock);
1523 +#endif
1525 +static int
1526 +secure_getgrnam (const char *name, struct group *grbuf, char *buf, size_t buflen)
1528 +#ifndef HAVE_GETGRNAM_R
1529 + size_t gr_name_len = 0;
1530 + size_t gr_passwd_len = 0;
1531 + char *ptr;
1532 + struct group *tmp;
1534 + G_LOCK(getgrnam_lock);
1536 + tmp = getgrnam (name);
1537 + if (tmp == NULL)
1538 + return errno;
1540 + if (tmp->gr_name) gr_name_len = strlen(tmp->gr_name);
1541 + if (tmp->gr_passwd) gr_passwd_len = strlen(tmp->gr_passwd);
1543 + if ((gr_name_len + gr_passwd_len) > buflen)
1544 + return ERANGE;
1546 + memset (buf, 0, buflen);
1547 + ptr = buf;
1549 + grbuf->gr_gid = tmp->gr_gid;
1551 + if (tmp->gr_name) {
1552 + memcpy (ptr, tmp->gr_name, gr_name_len);
1553 + grbuf->gr_name = ptr;
1554 + ptr += gr_name_len + 1;
1557 + if (tmp->gr_passwd) {
1558 + memcpy (ptr, tmp->gr_passwd, gr_passwd_len);
1559 + grbuf->gr_passwd = ptr;
1560 + ptr += gr_passwd_len + 1;
1563 + // TODO: Duplicate char **tmp->gr_mem
1565 + G_UNLOCK(getgrnam_lock);
1566 + return 0;
1568 +#elif HAVE_GETGRNAM_R_5
1569 + struct group *tmp;
1571 + return getgrnam_r (name, grbuf, buf, buflen, &tmp);
1573 +#elif HAVE_GETGRNAM_R_4
1575 + return getgrnam_r (name, grbuf, buf, buflen);
1576 +#endif
1578 + return 0;
1581 +void
1582 +get_access_info_acl (GnomeVFSFileInfo *file_info,
1583 + const gchar *full_name)
1585 + GList *acls, *iter;
1586 + GnomeVFSACL *acl;
1588 + acls = gnome_vfs_acl_get_ace_list (file_info->acl);
1590 + for (iter = acls; iter; iter = iter->next) {
1591 + int i, re;
1592 + const char *id;
1593 + uid_t uid;
1594 + gid_t gid;
1595 + struct group *group;
1596 + GnomeVFSACE *ace;
1597 + int sup_groups_num;
1598 + gid_t sup_groups[NGROUPS_MAX];
1599 + struct passwd *passwd;
1600 + struct passwd pwd;
1601 + struct group grp;
1602 + char buf[1024];
1604 + ace = iter->data;
1606 + id = gnome_vfs_ace_get_id (ace);
1607 + if (id == NULL) continue;
1609 + /* User */
1610 + re = secure_getpwnam (id, &pwd, buf, 1024);
1611 + if (re == 0) {
1612 + uid = passwd->pw_uid;
1613 + } else {
1614 + errno = 0;
1615 + uid = atoi (id);
1616 + if (errno != 0)
1617 + continue;
1618 + }
1620 + /* Group */
1621 + group = secure_getgrnam (id, &grp, buf, 1024);
1622 + if (group != NULL) {
1623 + gid = group->gr_gid;
1624 + } else {
1625 + errno = 0;
1626 + gid = atoi (id);
1627 + if (errno != 0)
1628 + continue;
1631 + /* Suplementary groups */
1632 + sup_groups_num = getgroups(NGROUPS_MAX, sup_groups);
1634 + if ((file_info->uid == uid) ||
1635 + (file_info->gid == gid))
1637 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_READ))
1638 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_READABLE;
1639 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_WRITE))
1640 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_WRITABLE;
1641 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_EXECUTE))
1642 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_EXECUTABLE;
1643 + }
1646 + for (i = 0; i < sup_groups_num; i++) {
1647 + if (gid == sup_groups[i]) {
1648 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_READ))
1649 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_READABLE;
1650 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_WRITE))
1651 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_WRITABLE;
1652 + if (gnome_vfs_ace_check_perm (ace,GNOME_VFS_ACL_EXECUTE))
1653 + file_info->permissions |= GNOME_VFS_PERM_ACCESS_EXECUTABLE;
1658 + gnome_vfs_acl_free_ace_list (acls);
1661 --- gnome-vfs-2.17.2-orig/modules/file-method-acl.h 2007-04-10 01:50:02.776836000 +0200
1662 +++ gnome-vfs-2.17.2-alo/modules/file-method-acl.h 2007-04-03 12:35:34.720317000 +0200
1663 @@ -43,6 +43,11 @@
1664 const GnomeVFSFileInfo *info,
1665 GnomeVFSContext *context);
1667 +void get_access_info_acl (GnomeVFSFileInfo *info,
1668 + const gchar *path);
1670 +GnomeVFSACLScheme get_acl_scheme (GnomeVFSFileInfo *info);
1672 G_END_DECLS
1675 --- gnome-vfs-2.17.2-orig/modules/file-method.c 2007-04-10 01:50:02.776629000 +0200
1676 +++ gnome-vfs-2.17.2-alo/modules/file-method.c 2007-04-03 12:35:34.605073000 +0200
1677 @@ -863,6 +860,10 @@
1679 #endif
1681 + if (file_info->acl) {
1682 + get_access_info_acl (file_info, full_name);
1685 file_info->valid_fields |= GNOME_VFS_FILE_INFO_FIELDS_ACCESS;
1688 --- gnome-vfs-2.17.2-orig/test/test-acl.c 2007-04-10 01:50:02.503796000 +0200
1689 +++ gnome-vfs-2.17.2-alo/test/test-acl.c 2007-04-03 12:35:22.152136000 +0200
1690 @@ -94,8 +94,8 @@
1692 g_print ("Testing ACE Object\n");
1694 - a = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, "a", pset_a);
1695 - b = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, "a", NULL);
1696 + a = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, "a", pset_a, GNOME_VFS_ACL_TYPE_NULL, GNOME_VFS_ACL_SCHEME_CLASSIC);
1697 + b = gnome_vfs_ace_new (GNOME_VFS_ACL_USER, "a", NULL, GNOME_VFS_ACL_TYPE_NULL, GNOME_VFS_ACL_SCHEME_CLASSIC);
1699 TEST_ASSERT (a != NULL);
1700 TEST_ASSERT (b != NULL);