@@ -188,6 +188,20 @@ get_gid_from_archive(struct archive_entry *ae)
188
188
return (grent .gr_gid );
189
189
}
190
190
191
+ static int
192
+ set_chflags (int fd , const char * path , u_long fflags )
193
+ {
194
+ #ifdef HAVE_CHFLAGSAT
195
+ if (getenv ("INSTALL_AS_USER" ))
196
+ return (EPKG_OK );
197
+ if (fflags == 0 )
198
+ return (EPKG_OK );
199
+ if (chflagsat (fd , RELATIVE_PATH (path ), fflags , AT_SYMLINK_NOFOLLOW ) == -1 ) {
200
+ pkg_fatal_errno ("Fail to chflags %s" , path );
201
+ }
202
+ #endif
203
+ return (EPKG_OK );
204
+ }
191
205
int
192
206
set_attrsat (int fd , const char * path , mode_t perm , uid_t uid , gid_t gid ,
193
207
const struct timespec * ats , const struct timespec * mts )
@@ -428,6 +442,9 @@ create_symlinks(struct pkg *pkg, struct pkg_file *f, const char *target, tempdir
428
442
& f -> time [0 ], & f -> time [1 ]) != EPKG_OK ) {
429
443
return (EPKG_FATAL );
430
444
}
445
+ if (tmpdir != NULL )
446
+ set_chflags (fd , path , f -> fflags );
447
+
431
448
return (EPKG_OK );
432
449
}
433
450
@@ -651,6 +668,8 @@ create_regfile(struct pkg *pkg, struct pkg_file *f, struct archive *a,
651
668
if (set_attrsat (fd , path , f -> perm , f -> uid , f -> gid ,
652
669
& f -> time [0 ], & f -> time [1 ]) != EPKG_OK )
653
670
return (EPKG_FATAL );
671
+ if (tmpdir != NULL )
672
+ set_chflags (fd , path , f -> fflags );
654
673
655
674
return (EPKG_OK );
656
675
}
@@ -861,14 +880,8 @@ pkg_extract_finalize(struct pkg *pkg, tempdirs_t *tempdirs)
861
880
f -> temppath , fto );
862
881
}
863
882
864
- #ifdef HAVE_CHFLAGSAT
865
- if (!install_as_user && f -> fflags != 0 ) {
866
- if (chflagsat (pkg -> rootfd , RELATIVE_PATH (fto ),
867
- f -> fflags , AT_SYMLINK_NOFOLLOW ) == -1 ) {
868
- pkg_fatal_errno ("Fail to chflags %s" , fto );
869
- }
870
- }
871
- #endif
883
+ if (set_chflags (pkg -> rootfd , fto , f -> fflags ) != EPKG_OK )
884
+ return (EPKG_FATAL );
872
885
}
873
886
874
887
while (pkg_dirs (pkg , & d ) == EPKG_OK ) {
@@ -878,6 +891,8 @@ pkg_extract_finalize(struct pkg *pkg, tempdirs_t *tempdirs)
878
891
if (set_attrsat (pkg -> rootfd , d -> path , d -> perm ,
879
892
d -> uid , d -> gid , & d -> time [0 ], & d -> time [1 ]) != EPKG_OK )
880
893
return (EPKG_FATAL );
894
+ if (set_chflags (pkg -> rootfd , d -> path , d -> fflags ) != EPKG_OK )
895
+ return (EPKG_FATAL );
881
896
}
882
897
if (tempdirs != NULL )
883
898
tll_free (* tempdirs );
0 commit comments