From c03e70981ba9ae4a4c2ffd54f67911f92b7d50d4 Mon Sep 17 00:00:00 2001 From: didg Date: Wed, 25 May 2005 18:24:24 +0000 Subject: [PATCH] for volume with unix priv don't use parent folder permission when creating files. --- include/atalk/adouble.h | 4 +++- libatalk/adouble/ad_open.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index c12924f2..8a04a23a 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -1,5 +1,5 @@ /* - * $Id: adouble.h,v 1.27 2005-05-25 18:19:33 didg Exp $ + * $Id: adouble.h,v 1.28 2005-05-25 18:24:24 didg Exp $ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * @@ -275,6 +275,8 @@ struct adouble { /* adouble v2 cnid cache */ #define ADVOL_NODEV (1 << 0) #define ADVOL_CACHE (1 << 1) +/* adouble unix priv */ +#define ADVOL_UNIXPRIV (1 << 2) /* lock flags */ #define ADLOCK_CLR (0) diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 6660132a..9451efff 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1,5 +1,5 @@ /* - * $Id: ad_open.c,v 1.34 2005-05-14 12:54:55 didg Exp $ + * $Id: ad_open.c,v 1.35 2005-05-25 18:24:24 didg Exp $ * * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -484,6 +484,7 @@ mode_t ad_hf_mode (mode_t mode) #if 0 mode |= S_IRUSR; #endif + mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH); /* fnctl lock need write access */ if ((mode & S_IRUSR)) mode |= S_IWUSR; @@ -1055,7 +1056,7 @@ int ad_open( path, adflags, oflags, mode, ad ) struct stat st; char *ad_p; int hoflags, admode; - int st_invalid; + int st_invalid = -1; int open_df = 0; if (ad->ad_inited != AD_INITED) { @@ -1071,12 +1072,17 @@ int ad_open( path, adflags, oflags, mode, ad ) if (ad_dfileno(ad) == -1) { hoflags = (oflags & ~(O_RDONLY | O_WRONLY)) | O_RDWR; admode = mode; - st_invalid = ad_mode_st(path, &admode, &st); + if ((oflags & O_CREAT)) { + st_invalid = ad_mode_st(path, &admode, &st); + if ((ad->ad_options & ADVOL_UNIXPRIV)) { + admode = mode; + } + } ad->ad_df.adf_fd =open( path, hoflags, admode ); if (ad->ad_df.adf_fd < 0 ) { if ((errno == EACCES || errno == EROFS) && !(oflags & O_RDWR)) { hoflags = oflags; - ad->ad_df.adf_fd =open( path, hoflags, admode ); + ad->ad_df.adf_fd = open( path, hoflags, admode ); } } if ( ad->ad_df.adf_fd < 0) @@ -1084,7 +1090,7 @@ int ad_open( path, adflags, oflags, mode, ad ) AD_SET(ad->ad_df.adf_off); ad->ad_df.adf_flags = hoflags; - if ((oflags & O_CREAT) && !st_invalid) { + if (!st_invalid) { /* just created, set owner if admin (root) */ ad_chown(path, &st); } @@ -1151,6 +1157,9 @@ int ad_open( path, adflags, oflags, mode, ad ) admode = mode; errno = 0; st_invalid = ad_mode_st(ad_p, &admode, &st); + if ((ad->ad_options & ADVOL_UNIXPRIV)) { + admode = mode; + } admode = ad_hf_mode(admode); if ( errno == ENOENT && !(adflags & ADFLAGS_NOADOUBLE) && ad->ad_flags != AD_VERSION2_OSX) { if (ad->ad_mkrf( ad_p) < 0) { @@ -1158,6 +1167,9 @@ int ad_open( path, adflags, oflags, mode, ad ) } admode = mode; st_invalid = ad_mode_st(ad_p, &admode, &st); + if ((ad->ad_options & ADVOL_UNIXPRIV)) { + admode = mode; + } admode = ad_hf_mode(admode); } /* retry with O_CREAT */ -- 2.39.2