Lines Matching refs:attr

162  *     - replace <attr/xattr.h> by <sys/xattr.h> (provided by glibc)
345 #define MAXATTRSZ 65536 /* Max sec attr size (16448 met for WinXP) */
468 char *attr;
706 static unsigned int get2l(const char *attr, int p)
713 v += (attr[p+i] & 255) << (8*i);
717 static unsigned long get4l(const char *attr, int p)
724 v += ((long)(attr[p+i] & 255)) << (8*i);
728 static u64 get6h(const char *attr, int p)
735 v = (v << 8) + (attr[p+i] & 255);
739 static u64 get8l(const char *attr, int p)
746 v += ((long long)(attr[p+i] & 255)) << (8*i);
775 static void hexdump(const char *attr, int size, int level)
784 printf((j & 3 ? "%02x" : " %02x"),attr[j] & 255);
930 static BOOL guess_dir(const char *attr)
939 off = get4l(attr,16);
941 cnt = get2l(attr,off+4);
944 if (attr[off + x + 1] & 3)
946 x += get2l(attr,off + x + 2);
957 static void showsid(const char *attr, int off, const char *prefix, int level)
972 cnt = attr[off+1] & 255;
973 auth = get6h(attr,off+2);
976 if ((attr[off] == 1) /* revision */
979 first = get4l(attr,off+8);
1056 second = get4l(attr,off+12);
1080 second = get4l(attr,off+12);
1081 last = get4l(attr,off+4+4*cnt);
1113 printf("%*c%shex S-%x-",-level,marker,prefix,attr[off] & 255);
1116 printf("-%lx",get4l(attr,off+8+4*i));
1118 printf("%*c%sdec S-%u-",-level,marker,prefix,attr[off] & 255);
1121 printf("-%lu",get4l(attr,off+8+4*i));
1125 static void showusid(const char *attr, int level)
1137 off = get4l(attr,4);
1138 showsid(attr,off,"O:",level+4);
1141 static void showgsid(const char *attr, int level)
1153 off = get4l(attr,8);
1154 showsid(attr,off,"G:",level+4);
1157 static void showownership(const char *attr)
1177 off = get4l(attr,4);
1178 sid = &attr[off];
1183 off = get4l(attr,8);
1184 sid = &attr[off];
1190 off = get4l(attr,4);
1192 sid = (const char*)ntfs_acl_owner((const char*)attr);
1194 (const SID*)&attr[off]))
1229 static void showheader(const char *attr, int level)
1241 printf("%*crevision %d\n",-level-4,marker,attr[0]);
1242 flags = get2l(attr,2);
1273 printf("%*cOff USID 0x%x\n",-level-4,marker,(int)get4l(attr,4));
1274 printf("%*cOff GSID 0x%x\n",-level-4,marker,(int)get4l(attr,8));
1275 printf("%*cOff SACL 0x%x\n",-level-4,marker,(int)get4l(attr,12));
1276 printf("%*cOff DACL 0x%x\n",-level-4,marker,(int)get4l(attr,16));
1279 static void showace(const char *attr, int off, int isdir, int level)
1289 printf("%*ctype %d\n",-level,marker,attr[off]);
1290 switch (attr[off]) {
1304 flags = attr[off+1] & 255;
1321 printf("%*cSize 0x%x\n",-level,marker,get2l(attr,off+2));
1323 rights = get4l(attr,off+4);
1388 showsid(attr,off+8,"",level+4);
1390 if (attr[off] == 0)
1392 if (attr[off] == 1)
1410 sz = attr[off+9]*4 + 8;
1411 if (!memcmp(&attr[off+8],&attr[get4l(attr,4)],sz))
1413 if (!memcmp(&attr[off+8],&attr[get4l(attr,8)],sz))
1420 static void showacl(const char *attr, int off, int isdir, int level)
1432 size = get2l(attr,off+2);
1433 printf("%*crevision %d\n",-level,marker,attr[off]);
1435 cnt = get2l(attr,off+4);
1440 showace(attr,off + x,isdir,level+4);
1441 x += get2l(attr,off + x + 2);
1445 static void showdacl(const char *attr, int isdir, int level)
1454 off = get4l(attr,16);
1459 showacl(attr,off,isdir,level+4);
1467 static void showsacl(const char *attr, int isdir, int level)
1476 off = get4l(attr,12);
1481 showacl(attr,off,isdir,level+4);
1490 static void showall(const char *attr, int level)
1494 isdir = guess_dir(attr);
1495 showheader(attr,level);
1496 showusid(attr,level);
1497 showgsid(attr,level);
1498 showdacl(attr,isdir,level);
1499 showsacl(attr,isdir,level);
1623 static struct POSIX_SECURITY *linux_permissions_posix(const char *attr, BOOL isdir)
1633 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
1634 gsid = (const SID*)&attr[le32_to_cpu(phead->group)];
1636 osid = (const SID*)&attr[le32_to_cpu(phead->owner)];
1637 usid = ntfs_acl_owner((const char*)attr);
1646 usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
1651 (const char*)attr, usid, gsid, isdir);
1654 (const char*)attr, usid, gsid, isdir);
1664 static int linux_permissions(const char *attr, BOOL isdir)
1674 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
1675 gsid = (const SID*)&attr[le32_to_cpu(phead->group)];
1677 osid = (const SID*)&attr[le32_to_cpu(phead->owner)];
1678 usid = ntfs_acl_owner((const char*)attr);
1687 usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
1689 perm = ntfs_build_permissions((const char*)attr, usid, gsid, isdir);
1697 static uid_t linux_owner(const char *attr)
1703 usid = ntfs_acl_owner((const char*)attr);
1707 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
1708 usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
1721 static gid_t linux_group(const char *attr)
1727 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
1728 gsid = (const SID*)&attr[le32_to_cpu(phead->group)];
1754 psecurdata->attr = (char*)NULL;
1768 if (psecurdata->attr)
1769 free(psecurdata->attr);
2071 static char attr[MAXATTRSZ];
2114 && (pos > get4l(attr,4))
2115 && (pos > get4l(attr,8))
2116 && (pos > get4l(attr,12))
2117 && (pos > get4l(attr,16))
2118 && (pos >= ntfs_attr_size(attr));
2121 (unsigned long)hash((le32*)attr,
2122 ntfs_attr_size(attr)));
2123 isdir = guess_dir(attr);
2126 if (!ntfs_valid_descr((char*)attr,pos)) {
2131 showheader(attr,4);
2132 showusid(attr,4);
2133 showgsid(attr,4);
2134 showdacl(attr,isdir,4);
2135 showsacl(attr,isdir,4);
2136 showownership(attr);
2137 mode = linux_permissions(attr,isdir);
2145 pxdesc = linux_permissions_posix(attr,isdir);
2160 pattr = (le32*)&attr[pos];
2182 static BOOL applyattr(const char *fullname, const char *attr,
2221 newattr = (char*)malloc(ntfs_attr_size(attr));
2223 memcpy(newattr,attr,ntfs_attr_size(attr));
2224 psecurdata->attr = newattr;
2227 curattr = attr;
2230 * No explicit attr in backup, use attr defined
2234 curattr = psecurdata->attr;
2275 static char attr[MAXATTRSZ];
2326 if ((!isdump || !off) && pos && ntfs_valid_descr((char*)attr,pos)) {
2330 (unsigned long)hash((le32*)attr,
2331 ntfs_attr_size(attr)));
2332 isdir = guess_dir(attr);
2334 showheader(attr,4);
2335 showusid(attr,4);
2336 showgsid(attr,4);
2337 showdacl(attr,isdir,4);
2338 showsacl(attr,isdir,4);
2339 mode = linux_permissions(attr,isdir);
2340 showownership(attr);
2351 pattr = (le32*)&attr[pos];
2395 && (hash((const le32*)attr,ntfs_attr_size(attr)) != oldhash)) {
2400 phead = (SECURITY_DESCRIPTOR_RELATIVE*)attr;
2404 if (!applyattr(fullname,attr,withattr,
2571 char *attr;
2591 attr = ntfs_build_descr_posix(context.mapping,newpxdesc,
2593 if (attr && ntfs_valid_descr(attr, ntfs_attr_size(attr))) {
2595 hexdump(attr,ntfs_attr_size(attr),8);
2597 showheader(attr,4);
2598 showusid(attr,4);
2599 showgsid(attr,4);
2600 showdacl(attr,isdir,4);
2601 showsacl(attr,isdir,4);
2602 mode = linux_permissions(attr,isdir);
2605 newpxdesc = linux_permissions_posix(attr,isdir);
2610 oldattr = attr;
2629 char *attr;
2663 attr = (char*)ntfs_malloc(attrsz);
2664 if (attr) {
2666 pnhead = (SECURITY_DESCRIPTOR_RELATIVE*) attr;
2681 pacl = (ACL*)&attr[pos];
2694 pace = (ACCESS_ALLOWED_ACE*)&attr[pos];
2716 memcpy(&attr[pos], usid, usidsz);
2720 memcpy(&attr[pos + usidsz], gsid, gsidsz);
2731 if (!ntfs_valid_descr(attr,pos+usidsz+gsidsz)) {
2733 free(attr);
2734 attr = (char*)NULL;
2739 return (attr);
3168 char *attr;
3213 attr = ntfs_build_descr(perm,isdir,owner,(const SID*)group);
3214 if (attr && ntfs_valid_descr(attr, ntfs_attr_size(attr))) {
3215 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
3216 pacl = (const ACL*)&attr[le32_to_cpu(phead->dacl)];
3218 globhash += hash((const le32*)attr,ntfs_attr_size(attr));
3226 pxdesc = linux_permissions_posix(attr, isdir);
3242 if (pxattr && !memcmp(pxattr,attr,
3243 ntfs_attr_size(attr))) {
3244 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
3245 pacl = (const ACL*)&attr[le32_to_cpu(phead->dacl)];
3247 pxglobhash += hash((const le32*)attr,ntfs_attr_size(attr));
3256 free(attr);
3260 gotback = linux_permissions(attr, isdir);
3264 free(attr);
3273 if (attr && opt_v)
3274 hexdump(attr,ntfs_attr_size(attr),8);
3275 if (attr && (opt_v >= 2)) {
3276 showheader(attr,4);
3277 showusid(attr,4);
3278 showgsid(attr,4);
3279 showdacl(attr,isdir,4);
3280 showsacl(attr,isdir,4);
3315 hexdump(attr,ntfs_attr_size(attr),8);
3317 showheader(attr,4);
3318 showusid(attr,4);
3319 showgsid(attr,4);
3320 showdacl(attr,isdir,4);
3321 showsacl(attr,isdir,4);
3324 free(attr);
3655 static unsigned int getfull(char *attr, const char *fullname)
3689 (char*)attr,MAXATTRSZ,&attrsz)) {
3691 set4l(attr,0);
3692 attr[0] = SECURITY_DESCRIPTOR_REVISION;
3693 set4l(&attr[12],0);
3701 set4l(&attr[16],0);
3706 memcpy(&attr[attrsz],&part[20],partsz-20);
3707 set4l(&attr[16],(partsz > 20 ? attrsz : 0));
3708 set2l(&attr[2],get2l(attr,2) | (get2l(part,2)
3730 memcpy(&attr[attrsz],ownsid,ownersz);
3731 set4l(&attr[4],attrsz);
3732 set2l(&attr[2],get2l(attr,2)
3736 set4l(&attr[4],0);
3741 set4l(&attr[8],0);
3746 memcpy(&attr[attrsz],&part[20],partsz-20);
3747 set4l(&attr[8],(partsz > 20 ? attrsz : 0));
3748 set2l(&attr[2],get2l(attr,2) | (get2l(part,2)
3765 if (!ntfs_valid_descr((char*)attr,attrsz)) {
3783 static BOOL updatefull(const char *name, u32 flags, char *attr)
3788 err = !ntfs_set_file_security(ntfs_context, name, flags, attr);
3807 static char attr[MAXATTRSZ];
3829 attrsz = getfull(attr, fullname);
3831 oldpxdesc = linux_permissions_posix(attr, isdir);
3857 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
3858 gsid = (const SID*)&attr[le32_to_cpu(phead->group)];
3860 osid = (const SID*)&attr[le32_to_cpu(phead->owner)];
3861 usid = ntfs_acl_owner((const char*)attr);
3865 usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
3921 static char attr[MAXATTRSZ];
3936 attrsz = getfull(attr, fullname);
3939 phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
3940 gsid = (const SID*)&attr[le32_to_cpu(phead->group)];
3942 osid = (const SID*)&attr[le32_to_cpu(phead->owner)];
3943 usid = ntfs_acl_owner((const char*)attr);
3947 usid = (const SID*)&attr[le32_to_cpu(phead->owner)];
3982 static BOOL proposal(const char *name, const char *attr)
4005 uoff = get4l(attr,4);
4006 uauth = get6h(attr,uoff+2);
4007 ucnt = attr[uoff+1] & 255;
4008 goff = get4l(attr,8);
4009 gauth = get6h(attr,goff+2);
4010 gcnt = attr[goff+1] & 255;
4014 && (get4l(attr,uoff+8) == 21) && (get4l(attr,goff+8) == 21)) {
4021 printf("S-%d-%llu",attr[uoff] & 255,(long long)uauth);
4023 printf("-%lu",get4l(attr,uoff+8+4*i));
4029 printf("S-%d-%llu",attr[goff] & 255,(long long)gauth);
4031 printf("-%lu",get4l(attr,goff+8+4*i));
4034 printf("::S-%d-%llu",attr[goff] & 255,(long long)gauth);
4036 printf("-%lu",get4l(attr,goff+8+4*i));
4112 static char attr[MAXATTRSZ];
4175 attrsz = getfull(attr, fullname);
4191 (unsigned long)hash((le32*)attr,attrsz));
4193 memcpy(newattr,attr,attrsz);
4194 psecurdata->attr = newattr;
4203 hexdump(attr,attrsz,8);
4205 (unsigned long)hash((le32*)attr,attrsz));
4207 if (ntfs_valid_descr((char*)attr,attrsz)) {
4209 pxdesc = linux_permissions_posix(attr,isdir);
4215 mode = linux_permissions(attr,isdir);
4220 showheader(attr,level);
4221 showusid(attr,level);
4222 showgsid(attr,level);
4223 showdacl(attr,isdir,level);
4224 showsacl(attr,isdir,level);
4228 uid = linux_owner(attr);
4229 gid = linux_group(attr);
4231 showownership(attr);
4235 showownership(attr);
4286 && psecurdata->attr) {
4290 (unsigned long)hash((le32*)psecurdata->attr,
4291 ntfs_attr_size(psecurdata->attr)));
4394 static char attr[MAXATTRSZ];
4416 attrsz = ntfs_getxattr(fullname,"system.ntfs_acl",attr,MAXATTRSZ);
4419 hexdump(attr,attrsz,8);
4421 (unsigned long)hash((le32*)attr,attrsz));
4428 if (ntfs_valid_descr(attr,attrsz)) {
4432 pxdesc = linux_permissions_posix(attr,isdir);
4439 mode = linux_permissions(attr,isdir);
4444 mode = linux_permissions(attr,isdir);
4448 showheader(attr,level);
4449 showusid(attr,level);
4450 showgsid(attr,level);
4451 showdacl(attr,isdir,level);
4452 showsacl(attr,isdir,level);
4454 showownership(attr);
4456 uid = linux_owner(attr);
4457 gid = linux_group(attr);
4495 static char attr[MAXATTRSZ];
4505 attrsz = ntfs_getxattr(fullname,"system.ntfs_acl",attr,MAXATTRSZ);
4508 hexdump(attr,attrsz,8);
4510 (unsigned long)hash((le32*)attr,attrsz));
4512 if (ntfs_valid_descr(attr,attrsz)) {
4513 err = proposal(fullname, attr);
4815 char attr[256]; /* header (20) and a couple of SIDs (max 68 each) */
4825 (char*)attr,MAXATTRSZ,&attrsz);
4827 err = proposal(name,attr);
4858 static BOOL valid_sds(const char *attr, unsigned int offset,
4867 if (!get4l(attr,0) && !get4l(attr,4)) {
4870 if ((ntfs_attr_size(&attr[20]) + 20) > entrysz) {
4872 (long)ntfs_attr_size(&attr[20] + 20));
4876 if ((ntfs_attr_size(&attr[20]) + 20) < entrysz) {
4878 (long)ntfs_attr_size(&attr[20]) + 20);
4881 if (!unsane && !ntfs_valid_descr((const char*)&attr[20],size)) {
4887 comphash = hash((const le32*)&attr[20],entrysz-20);
4888 if ((u32)get4l(attr,0) == comphash) {
4894 (unsigned long)get4l(attr,0),
4901 if ((second ? get8l(attr,8) + 0x40000 : get8l(attr,8)) == offset) {
4906 (long long)get8l(attr,8),
4907 (long long)(second ? get8l(attr,8) - 0x40000 : get8l(attr,8)));
4913 key = get4l(attr,4);
4934 static int consist_sds(const char *attr, unsigned int offset,
4943 key = get4l(attr,4);
4951 comphash = hash((const le32*)&attr[20],entrysz-20);
4960 if (psecurdata->offset != get8l(attr,8)) {
4962 (long long)psecurdata->offset,(long long)get8l(attr,8));
4966 if (psecurdata->length != get4l(attr,16)) {
4968 (long)psecurdata->length,(long)get4l(attr,16));
4979 psecurdata->offset = get8l(attr,8);
4980 psecurdata->length = get4l(attr,16);
4985 if (key || get4l(attr,0)) {
4999 static char attr[MAXATTRSZ + 20];
5026 size = ntfs_read_sds(ntfs_context,(char*)attr,20,offset);
5039 entrysz = get4l(attr,16);
5044 (char*)&attr[20],entryalsz,offset + 20);
5057 hexdump(&attr[20],size,8);
5060 unsane = !valid_sds(attr,offset,entrysz,
5063 if (!get4l(attr,0) && !get4l(attr,4))
5067 errcnt += consist_sds(attr,offset,
5070 isdir = guess_dir(&attr[20]);
5072 showheader(&attr[20],0);
5073 showusid(&attr[20],0);
5074 showgsid(&attr[20],0);
5075 showdacl(&attr[20],isdir,0);
5076 showsacl(&attr[20],isdir,0);
5077 showownership(&attr[20]);
5079 &attr[20],isdir);
5082 prevkey = get4l(attr,4);
5085 memcpy(attr,&attr[entryalsz],20);
5087 if (!get4l(attr,16)
5097 (char*)attr,20,offset);