Fork me on GitHub

root/kernel/syscalls/setuid.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. sys_setuid

   1 /*
   2  * fiwix/kernel/syscalls/setuid.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/types.h>
   9 #include <fiwix/process.h>
  10 #include <fiwix/errno.h>
  11 
  12 #ifdef __DEBUG__
  13 #include <fiwix/stdio.h>
  14 #endif /*__DEBUG__ */
  15 
  16 int sys_setuid(__uid_t uid)
  17 {
  18 #ifdef __DEBUG__
  19         printk("(pid %d) sys_setuid(%d)\n", current->pid, uid);
  20 #endif /*__DEBUG__ */
  21 
  22         if(IS_SUPERUSER) {
  23                 current->uid = current->suid = uid;
  24         } else {
  25                 if((current->uid != uid) && (current->suid != uid)) {
  26                         return -EPERM;
  27                 }
  28         }
  29         current->euid = uid;
  30         return 0;
  31 }

/* [previous][next][first][last][top][bottom][index][help] */