| 1 | |
| 2 | |
| 3 | void ExtractUnixOwner20(Archive &Arc,const wchar *FileName) |
| 4 | { |
| 5 | char NameA[NM]; |
| 6 | WideToChar(FileName,NameA,ASIZE(NameA)); |
| 7 | |
| 8 | if (Arc.BrokenHeader) |
| 9 | { |
| 10 | uiMsg(UIERROR_UOWNERBROKEN,Arc.FileName,FileName); |
| 11 | ErrHandler.SetErrorCode(RARX_CRC); |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | struct passwd *pw; |
| 16 | errno=0; // Required by getpwnam specification if we need to check errno. |
| 17 | if ((pw=getpwnam(Arc.UOHead.OwnerName))==NULL) |
| 18 | { |
| 19 | uiMsg(UIERROR_UOWNERGETOWNERID,Arc.FileName,GetWide(Arc.UOHead.OwnerName)); |
| 20 | ErrHandler.SysErrMsg(); |
| 21 | ErrHandler.SetErrorCode(RARX_WARNING); |
| 22 | return; |
| 23 | } |
| 24 | uid_t OwnerID=pw->pw_uid; |
| 25 | |
| 26 | struct group *gr; |
| 27 | errno=0; // Required by getgrnam specification if we need to check errno. |
| 28 | if ((gr=getgrnam(Arc.UOHead.GroupName))==NULL) |
| 29 | { |
| 30 | uiMsg(UIERROR_UOWNERGETGROUPID,Arc.FileName,GetWide(Arc.UOHead.GroupName)); |
| 31 | ErrHandler.SysErrMsg(); |
| 32 | ErrHandler.SetErrorCode(RARX_CRC); |
| 33 | return; |
| 34 | } |
| 35 | uint Attr=GetFileAttr(FileName); |
| 36 | gid_t GroupID=gr->gr_gid; |
| 37 | #if defined(SAVE_LINKS) && !defined(_APPLE) |
| 38 | if (lchown(NameA,OwnerID,GroupID)!=0) |
| 39 | #else |
| 40 | if (chown(NameA,OwnerID,GroupID)!=0) |
| 41 | #endif |
| 42 | { |
| 43 | uiMsg(UIERROR_UOWNERSET,Arc.FileName,FileName); |
| 44 | ErrHandler.SetErrorCode(RARX_CREATE); |
| 45 | } |
| 46 | SetFileAttr(FileName,Attr); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | void ExtractUnixOwner30(Archive &Arc,const wchar *FileName) |
no test coverage detected