Compare commits
4 Commits
cc72a1655d
...
fd62de6474
Author | SHA1 | Date | |
---|---|---|---|
fd62de6474 | |||
1090815c8d | |||
89d7866abb | |||
0540879959 |
@ -149,10 +149,28 @@ static Result<void> load_service(const os::Path& path)
|
|||||||
|
|
||||||
if (parts[0].view() == "Command")
|
if (parts[0].view() == "Command")
|
||||||
{
|
{
|
||||||
|
if (!service.command.is_empty())
|
||||||
|
{
|
||||||
|
fprintf(g_init_log, "[init] 'Command' cannot be specified after 'Script' has already been set! (%s)\n",
|
||||||
|
line.chars());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
service.command = move(parts[1]);
|
service.command = move(parts[1]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parts[0].view() == "Script")
|
||||||
|
{
|
||||||
|
if (!service.command.is_empty())
|
||||||
|
{
|
||||||
|
fprintf(g_init_log, "[init] 'Script' cannot be specified after 'Command' has already been set! (%s)\n",
|
||||||
|
line.chars());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
service.command = TRY(String::format("/bin/sh -- %s"_sv, parts[1].chars()));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (parts[0].view() == "Restart")
|
if (parts[0].view() == "Restart")
|
||||||
{
|
{
|
||||||
if (parts[1].view() == "true" || parts[1].view().to_uint().value_or(0) == 1)
|
if (parts[1].view() == "true" || parts[1].view().to_uint().value_or(0) == 1)
|
||||||
@ -210,7 +228,7 @@ static Result<void> load_service(const os::Path& path)
|
|||||||
|
|
||||||
if (service.command.is_empty())
|
if (service.command.is_empty())
|
||||||
{
|
{
|
||||||
fprintf(g_init_log, "[init] service file is missing 'Command' entry, aborting!\n");
|
fprintf(g_init_log, "[init] service file is missing 'Command' or 'Script' entry, aborting!\n");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
initrd/etc/init/00-tmpfs
Normal file
3
initrd/etc/init/00-tmpfs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Name=tmpfs
|
||||||
|
Script=/sbin/mount-tmpfs
|
||||||
|
Wait=true
|
3
initrd/sbin/mount-tmpfs
Normal file
3
initrd/sbin/mount-tmpfs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
mkdir -p /tmp
|
||||||
|
mount -t tmpfs /tmp
|
||||||
|
chmod 1777 /tmp
|
@ -168,6 +168,11 @@ namespace VFS
|
|||||||
return inode->mode() & S_ISGID;
|
return inode->mode() & S_ISGID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_sticky(SharedPtr<Inode> inode)
|
||||||
|
{
|
||||||
|
return inode->mode() & S_ISVTX;
|
||||||
|
}
|
||||||
|
|
||||||
bool is_seekable(SharedPtr<Inode> inode)
|
bool is_seekable(SharedPtr<Inode> inode)
|
||||||
{
|
{
|
||||||
return inode->type() != InodeType::FIFO && inode->type() != InodeType::CharacterDevice;
|
return inode->type() != InodeType::FIFO && inode->type() != InodeType::CharacterDevice;
|
||||||
|
@ -290,6 +290,7 @@ namespace VFS
|
|||||||
bool can_write(SharedPtr<Inode> inode, Credentials auth);
|
bool can_write(SharedPtr<Inode> inode, Credentials auth);
|
||||||
bool is_setuid(SharedPtr<Inode> inode);
|
bool is_setuid(SharedPtr<Inode> inode);
|
||||||
bool is_setgid(SharedPtr<Inode> inode);
|
bool is_setgid(SharedPtr<Inode> inode);
|
||||||
|
bool is_sticky(SharedPtr<Inode> inode);
|
||||||
|
|
||||||
bool is_seekable(SharedPtr<Inode> inode);
|
bool is_seekable(SharedPtr<Inode> inode);
|
||||||
|
|
||||||
|
@ -25,11 +25,12 @@ Result<u64> sys_unlinkat(Registers*, SyscallArgs args)
|
|||||||
auto inode = TRY(current->resolve_atfile(dirfd, dirname, false, false));
|
auto inode = TRY(current->resolve_atfile(dirfd, dirname, false, false));
|
||||||
if (!VFS::can_write(inode, current->auth)) return err(EACCES);
|
if (!VFS::can_write(inode, current->auth)) return err(EACCES);
|
||||||
|
|
||||||
if (flags > 0)
|
|
||||||
{
|
|
||||||
auto child = TRY(inode->find(basename.chars()));
|
auto child = TRY(inode->find(basename.chars()));
|
||||||
if (child->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
if (flags == AT_REMOVEDIR && child->type() != VFS::InodeType::Directory) return err(ENOTDIR);
|
||||||
}
|
|
||||||
|
if (current->auth.euid != 0 && VFS::is_sticky(inode) && current->auth.euid != inode->uid() &&
|
||||||
|
current->auth.euid != child->uid())
|
||||||
|
return err(EACCES);
|
||||||
|
|
||||||
TRY(inode->remove_entry(basename.chars()));
|
TRY(inode->remove_entry(basename.chars()));
|
||||||
|
|
||||||
|
@ -50,5 +50,6 @@ static void quicksort_impl(void* base, usize start, usize end, usize size, compa
|
|||||||
|
|
||||||
void c_quicksort(void* base, usize nmemb, usize size, compar_t compar)
|
void c_quicksort(void* base, usize nmemb, usize size, compar_t compar)
|
||||||
{
|
{
|
||||||
|
if (nmemb == 0) return;
|
||||||
quicksort_impl(base, 0, nmemb - 1, size, compar);
|
quicksort_impl(base, 0, nmemb - 1, size, compar);
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,7 @@ namespace os
|
|||||||
out[6] = (mode & S_ISGID) ? ((mode & S_IXGRP) ? 's' : 'S') : ((mode & S_IXGRP) ? 'x' : '-');
|
out[6] = (mode & S_ISGID) ? ((mode & S_IXGRP) ? 's' : 'S') : ((mode & S_IXGRP) ? 'x' : '-');
|
||||||
out[7] = (mode & S_IROTH) ? 'r' : '-';
|
out[7] = (mode & S_IROTH) ? 'r' : '-';
|
||||||
out[8] = (mode & S_IWOTH) ? 'w' : '-';
|
out[8] = (mode & S_IWOTH) ? 'w' : '-';
|
||||||
// FIXME: Support the sticky bit.
|
out[9] = (mode & S_ISVTX) ? ((mode & S_IXOTH) ? 't' : 'T') : ((mode & S_IXOTH) ? 'x' : '-');
|
||||||
out[9] = (mode & S_IXOTH) ? 'x' : '-';
|
|
||||||
out[10] = '\0';
|
out[10] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user