* The runtime_loader's test_executable() no longer analyzes the
executable permissions of the file by hand. We use _kern_access() instead, which also handles the root case correctly. * The user and group arguments of test_executable() aren't needed any longer. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24483 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
eb258077e7
commit
8560d1885b
@ -34,8 +34,7 @@ struct rld_export {
|
|||||||
int32 symbolType, void **_location);
|
int32 symbolType, void **_location);
|
||||||
status_t (*get_nth_image_symbol)(image_id imageID, int32 num, char *symbolName,
|
status_t (*get_nth_image_symbol)(image_id imageID, int32 num, char *symbolName,
|
||||||
int32 *nameLength, int32 *symbolType, void **_location);
|
int32 *nameLength, int32 *symbolType, void **_location);
|
||||||
status_t (*test_executable)(const char *path, uid_t user, gid_t group,
|
status_t (*test_executable)(const char *path, char *interpreter);
|
||||||
char *starter);
|
|
||||||
status_t (*get_next_image_dependency)(image_id id, uint32 *cookie,
|
status_t (*get_next_image_dependency)(image_id id, uint32 *cookie,
|
||||||
const char **_name);
|
const char **_name);
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ __get_next_image_dependency(image_id id, uint32 *cookie, const char **_name)
|
|||||||
status_t
|
status_t
|
||||||
__test_executable(const char *path, char *invoker)
|
__test_executable(const char *path, char *invoker)
|
||||||
{
|
{
|
||||||
return __gRuntimeLoader->test_executable(path, geteuid(), getegid(), invoker);
|
return __gRuntimeLoader->test_executable(path, invoker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -267,12 +267,11 @@ open_executable(char *name, image_type type, const char *rpath,
|
|||||||
both types, the caller will give scripts a proper treatment.
|
both types, the caller will give scripts a proper treatment.
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
test_executable(const char *name, uid_t user, gid_t group, char *invoker)
|
test_executable(const char *name, char *invoker)
|
||||||
{
|
{
|
||||||
char path[B_PATH_NAME_LENGTH];
|
char path[B_PATH_NAME_LENGTH];
|
||||||
char buffer[B_FILE_NAME_LENGTH];
|
char buffer[B_FILE_NAME_LENGTH];
|
||||||
// must be large enough to hold the ELF header
|
// must be large enough to hold the ELF header
|
||||||
struct stat stat;
|
|
||||||
status_t status;
|
status_t status;
|
||||||
ssize_t length;
|
ssize_t length;
|
||||||
int fd;
|
int fd;
|
||||||
@ -287,22 +286,10 @@ test_executable(const char *name, uid_t user, gid_t group, char *invoker)
|
|||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
// see if it's executable at all
|
// see if it's executable at all
|
||||||
|
status = _kern_access(path, X_OK);
|
||||||
status = _kern_read_stat(fd, NULL, true, &stat, sizeof(struct stat));
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
// shift mode bits, to check directly against accessMode
|
|
||||||
if (user == stat.st_uid)
|
|
||||||
stat.st_mode >>= 6;
|
|
||||||
else if (group == stat.st_gid)
|
|
||||||
stat.st_mode >>= 3;
|
|
||||||
|
|
||||||
if (~(stat.st_mode & S_IRWXO) & X_OK) {
|
|
||||||
status = B_NOT_ALLOWED;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read and verify the ELF header
|
// read and verify the ELF header
|
||||||
|
|
||||||
length = _kern_read(fd, 0, buffer, sizeof(buffer));
|
length = _kern_read(fd, 0, buffer, sizeof(buffer));
|
||||||
|
@ -25,8 +25,7 @@ extern "C" {
|
|||||||
int runtime_loader(void *arg);
|
int runtime_loader(void *arg);
|
||||||
int open_executable(char *name, image_type type, const char *rpath,
|
int open_executable(char *name, image_type type, const char *rpath,
|
||||||
const char *programPath);
|
const char *programPath);
|
||||||
status_t test_executable(const char *path, uid_t user, gid_t group,
|
status_t test_executable(const char *path, char *interpreter);
|
||||||
char *starter);
|
|
||||||
|
|
||||||
void terminate_program(void);
|
void terminate_program(void);
|
||||||
image_id load_program(char const *path, void **entry);
|
image_id load_program(char const *path, void **entry);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user