https://sourceware.org/bugzilla/show_bug.cgi?id=28729

--- Comment #2 from panxiaohe <panxh_ran at 163 dot com> ---
When eu-ar generates archive files,numbers of target file's permission which
are writen in archive file are octal numbers. But "eu -ar -tv archive" and
"eu-ar -x archive" commands treat numbers as decimalism. So it seems that "eu
-ar -tv archive" and "eu-ar -x archive" commands change file permission.

The following file is the example of archive file. 100600(octal number) is the
permission of test1.txt.
# cat test.a
!<arch>
test1.txt/ 1659685099 0 0 100600 14 `
dalfjdalflala

Anylze file permission in libelf/elf_begin.c.
-----------------------------------------------------
 968 #define INT_FIELD(FIELD)                                                  
   \
 969   do                                                                      
   \
 970     {                                                                     
   \
 971       char buf[sizeof (ar_hdr->FIELD) + 1];                               
   \
 972       const char *string = ar_hdr->FIELD;                                 
   \
 973       if (ar_hdr->FIELD[sizeof (ar_hdr->FIELD) - 1] != ' ')               
   \
 974         {                                                                 
   \
 975           *((char *) mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD)))
 \
 976             = '\0';                                                       
   \
 977           string = buf;                                                   
   \
 978         }                                                                 
   \
 979       if (sizeof (elf_ar_hdr->FIELD) <= sizeof (long int))                
   \
 980         elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) atol (string); 
   \
 981       else                                                                
   \
 982         elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) atoll (string);
   \
 983     }                                                                     
   \
 984   while (0)
 985
 986   INT_FIELD (ar_date);
 987   INT_FIELD (ar_uid);
 988   INT_FIELD (ar_gid);
 989   INT_FIELD (ar_mode);
 990   INT_FIELD (ar_size);
-----------------------------------------------------


Use file permission in libelf/elf_begin.c.
-----------------------------------------------------
 551                   printf ("%c%c%c%c%c%c%c%c%c %u/%u %6ju %s %s\n",
 552                           (arhdr->ar_mode & S_IRUSR) ? 'r' : '-',
 553                           (arhdr->ar_mode & S_IWUSR) ? 'w' : '-',
 554                           (arhdr->ar_mode & S_IXUSR)
 555                           ? ((arhdr->ar_mode & S_ISUID) ? 's' : 'x')
 556                           : ((arhdr->ar_mode & S_ISUID) ? 'S' : '-'),
 557                           (arhdr->ar_mode & S_IRGRP) ? 'r' : '-',
 558                           (arhdr->ar_mode & S_IWGRP) ? 'w' : '-',
 559                           (arhdr->ar_mode & S_IXGRP)
 560                           ? ((arhdr->ar_mode & S_ISGID) ? 's' : 'x')
 561                           : ((arhdr->ar_mode & S_ISGID) ? 'S' : '-'),
 562                           (arhdr->ar_mode & S_IROTH) ? 'r' : '-',
 563                           (arhdr->ar_mode & S_IWOTH) ? 'w' : '-',
 564                           (arhdr->ar_mode & S_IXOTH)
 565                           ? ((arhdr->ar_mode & S_ISVTX) ? 't' : 'x')
 566                           : ((arhdr->ar_mode & S_ISVTX) ? 'T' : '-'),
 567                           arhdr->ar_uid,
 568                           arhdr->ar_gid,
 569                           (uintmax_t) arhdr->ar_size,
 570                           datestr,
 571                           arhdr->ar_name);
-----------------------------------------------------

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to