MCPcopy Create free account
hub / github.com/apache/impala / FormatPermissions

Function FormatPermissions

be/src/rpc/authentication.cc:1250–1282  ·  view source on GitHub ↗

Helper function to format file permissions as a string (e.g., "drwxrwxrwt").

Source from the content-addressed store, hash-verified

1248
1249// Helper function to format file permissions as a string (e.g., "drwxrwxrwt").
1250string FormatPermissions(mode_t mode) {
1251 string result(10, '-');
1252
1253 // File type
1254 if (S_ISDIR(mode)) result[0] = 'd';
1255 else if (S_ISLNK(mode)) result[0] = 'l';
1256 else if (S_ISBLK(mode)) result[0] = 'b';
1257 else if (S_ISCHR(mode)) result[0] = 'c';
1258 else if (S_ISFIFO(mode)) result[0] = 'p';
1259 else if (S_ISSOCK(mode)) result[0] = 's';
1260
1261 // Owner permissions
1262 if (mode & S_IRUSR) result[1] = 'r';
1263 if (mode & S_IWUSR) result[2] = 'w';
1264 if (mode & S_IXUSR) result[3] = 'x';
1265
1266 // Group permissions
1267 if (mode & S_IRGRP) result[4] = 'r';
1268 if (mode & S_IWGRP) result[5] = 'w';
1269 if (mode & S_IXGRP) result[6] = 'x';
1270
1271 // Other permissions
1272 if (mode & S_IROTH) result[7] = 'r';
1273 if (mode & S_IWOTH) result[8] = 'w';
1274 if (mode & S_IXOTH) result[9] = 'x';
1275
1276 // Special bits (setuid, setgid, sticky)
1277 if (mode & S_ISUID) result[3] = (mode & S_IXUSR) ? 's' : 'S';
1278 if (mode & S_ISGID) result[6] = (mode & S_IXGRP) ? 's' : 'S';
1279 if (mode & S_ISVTX) result[9] = (mode & S_IXOTH) ? 't' : 'T';
1280
1281 return result;
1282}
1283
1284// Ensure that /var/tmp (the location of the Kerberos replay cache) has drwxrwxrwt
1285// permissions. If it doesn't, Kerberos will be unhappy in a way that's very difficult

Callers 2

TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68