public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "panxh_ran at 163 dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug tools/28729] After eu-ar -r added file into archive, it changes file permission
Date: Thu, 11 Aug 2022 15:11:43 +0000	[thread overview]
Message-ID: <bug-28729-10460-G88ZskNjhq@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28729-10460@http.sourceware.org/bugzilla/>

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.

  parent reply	other threads:[~2022-08-11 15:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 13:56 [Bug tools/28729] New: " panxh_ran at 163 dot com
2021-12-27 13:57 ` [Bug tools/28729] " panxh_ran at 163 dot com
2022-08-11 15:11 ` panxh_ran at 163 dot com [this message]
2022-08-28 18:28 ` mark at klomp dot org
2022-09-14 19:01 ` mark at klomp dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28729-10460-G88ZskNjhq@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).