@@ -347,14 +347,15 @@ ErrorOr<void> VirtualFileSystem::mknod(StringView path, mode_t mode, dev_t dev,
347
347
return existing_file_or_error.release_error ();
348
348
auto & parent_inode = parent_custody->inode ();
349
349
auto & current_process = Process::current ();
350
+ auto current_process_credentials = current_process.credentials ();
350
351
if (!parent_inode.metadata ().may_write (current_process))
351
352
return EACCES;
352
353
if (parent_custody->is_readonly ())
353
354
return EROFS;
354
355
355
356
auto basename = KLexicalPath::basename (path);
356
357
dbgln_if (VFS_DEBUG, " VirtualFileSystem::mknod: '{}' mode={} dev={} in {}" , basename, mode, dev, parent_inode.identifier ());
357
- (void )TRY (parent_inode.create_child (basename, mode, dev, current_process. euid (), current_process. egid ()));
358
+ (void )TRY (parent_inode.create_child (basename, mode, dev, current_process_credentials-> euid (), current_process_credentials-> egid ()));
358
359
return {};
359
360
}
360
361
@@ -372,14 +373,15 @@ ErrorOr<NonnullLockRefPtr<OpenFileDescription>> VirtualFileSystem::create(String
372
373
373
374
auto & parent_inode = parent_custody.inode ();
374
375
auto & current_process = Process::current ();
376
+ auto current_process_credentials = current_process.credentials ();
375
377
if (!parent_inode.metadata ().may_write (current_process))
376
378
return EACCES;
377
379
if (parent_custody.is_readonly ())
378
380
return EROFS;
379
381
380
382
dbgln_if (VFS_DEBUG, " VirtualFileSystem::create: '{}' in {}" , basename, parent_inode.identifier ());
381
- auto uid = owner.has_value () ? owner.value ().uid : current_process. euid ();
382
- auto gid = owner.has_value () ? owner.value ().gid : current_process. egid ();
383
+ auto uid = owner.has_value () ? owner.value ().uid : current_process_credentials-> euid ();
384
+ auto gid = owner.has_value () ? owner.value ().gid : current_process_credentials-> egid ();
383
385
384
386
auto inode = TRY (parent_inode.create_child (basename, mode, 0 , uid, gid));
385
387
auto custody = TRY (Custody::try_create (&parent_custody, basename, inode, parent_custody.mount_flags ()));
@@ -416,14 +418,15 @@ ErrorOr<void> VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba
416
418
TRY (validate_path_against_process_veil (*parent_custody, O_CREAT));
417
419
auto & parent_inode = parent_custody->inode ();
418
420
auto & current_process = Process::current ();
421
+ auto current_process_credentials = current_process.credentials ();
419
422
if (!parent_inode.metadata ().may_write (current_process))
420
423
return EACCES;
421
424
if (parent_custody->is_readonly ())
422
425
return EROFS;
423
426
424
427
auto basename = KLexicalPath::basename (path);
425
428
dbgln_if (VFS_DEBUG, " VirtualFileSystem::mkdir: '{}' in {}" , basename, parent_inode.identifier ());
426
- (void )TRY (parent_inode.create_child (basename, S_IFDIR | mode, 0 , current_process. euid (), current_process. egid ()));
429
+ (void )TRY (parent_inode.create_child (basename, S_IFDIR | mode, 0 , current_process_credentials-> euid (), current_process_credentials-> egid ()));
427
430
return {};
428
431
}
429
432
@@ -705,6 +708,7 @@ ErrorOr<void> VirtualFileSystem::symlink(StringView target, StringView linkpath,
705
708
return existing_custody_or_error.release_error ();
706
709
auto & parent_inode = parent_custody->inode ();
707
710
auto & current_process = Process::current ();
711
+ auto current_process_credentials = current_process.credentials ();
708
712
if (!parent_inode.metadata ().may_write (current_process))
709
713
return EACCES;
710
714
if (parent_custody->is_readonly ())
@@ -713,7 +717,7 @@ ErrorOr<void> VirtualFileSystem::symlink(StringView target, StringView linkpath,
713
717
auto basename = KLexicalPath::basename (linkpath);
714
718
dbgln_if (VFS_DEBUG, " VirtualFileSystem::symlink: '{}' (-> '{}') in {}" , basename, target, parent_inode.identifier ());
715
719
716
- auto inode = TRY (parent_inode.create_child (basename, S_IFLNK | 0644 , 0 , current_process. euid (), current_process. egid ()));
720
+ auto inode = TRY (parent_inode.create_child (basename, S_IFLNK | 0644 , 0 , current_process_credentials-> euid (), current_process_credentials-> egid ()));
717
721
718
722
auto target_buffer = UserOrKernelBuffer::for_kernel_buffer (const_cast <u8 *>((u8 const *)target.characters_without_null_termination ()));
719
723
MutexLocker locker (inode->m_inode_lock );
0 commit comments