@@ -57,8 +57,12 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
5757 xbps_dictionary_t pkg_filesd = arg ;
5858 const char * file = NULL , * sha256 = NULL ;
5959 char * path ;
60- bool mutable , test_broken = false;
60+ bool mutable , test_broken = false, noexist = false ;
6161 int rv = 0 , errors = 0 ;
62+ struct stat st ;
63+ mode_t mode ;
64+ uid_t uid ;
65+ gid_t gid ;
6266
6367 array = xbps_dictionary_get (pkg_filesd , "files" );
6468 if (array != NULL && xbps_array_count (array ) > 0 ) {
@@ -67,6 +71,7 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
6771 return -1 ;
6872
6973 while ((obj = xbps_object_iterator_next (iter ))) {
74+ noexist = false;
7075 xbps_dictionary_get_cstring_nocopy (obj , "file" , & file );
7176 /* skip noextract files */
7277 if (xhp -> noextract && xbps_patterns_match (xhp -> noextract , file ))
@@ -77,13 +82,11 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
7782 rv = xbps_file_sha256_check (path , sha256 );
7883 switch (rv ) {
7984 case 0 :
80- free (path );
8185 break ;
8286 case ENOENT :
8387 xbps_error_printf ("%s: unexistent file %s.\n" ,
8488 pkgname , file );
85- free (path );
86- test_broken = true;
89+ test_broken = noexist = true;
8790 break ;
8891 case ERANGE :
8992 mutable = false;
@@ -94,17 +97,47 @@ check_pkg_files(struct xbps_handle *xhp, const char *pkgname, void *arg)
9497 "for %s.\n" , pkgname , file );
9598 test_broken = true;
9699 }
97- free (path );
98100 break ;
99101 default :
100102 xbps_error_printf (
101103 "%s: can't check `%s' (%s)\n" ,
102104 pkgname , file , strerror (rv ));
103- free (path );
104105 break ;
105106 }
106- }
107- xbps_object_iterator_release (iter );
107+ if (!noexist ) {
108+ mode = uid = gid = 0 ;
109+ if (stat (path , & st ) == -1 ) {
110+ rv = errno ;
111+ xbps_error_printf (
112+ "%s: can't check `%s' (%s)\n" ,
113+ pkgname , file , strerror (rv ));
114+ } else {
115+ if (xbps_dictionary_get_uint32 (obj , "mode" , & mode )) {
116+ if (st .st_mode != mode ) {
117+ xbps_error_printf ("%s: mode mismatch "
118+ "for %s.\n" , pkgname , file );
119+ test_broken = true;
120+ }
121+ }
122+ if (xbps_dictionary_get_uint32 (obj , "uid" , & uid )) {
123+ if (st .st_uid != uid ) {
124+ xbps_error_printf ("%s: owner mismatch "
125+ "for %s.\n" , pkgname , file );
126+ test_broken = true;
127+ }
128+ }
129+ if (xbps_dictionary_get_uint32 (obj , "gid" , & gid )) {
130+ if (st .st_gid != gid ) {
131+ xbps_error_printf ("%s: group mismatch "
132+ "for %s.\n" , pkgname , file );
133+ test_broken = true;
134+ }
135+ }
136+ }
137+ }
138+ free (path );
139+ }
140+ xbps_object_iterator_release (iter );
108141 }
109142 if (test_broken ) {
110143 xbps_error_printf ("%s: files check FAILED.\n" , pkgname );
0 commit comments