当前位置:网站首页>用户权限和组权限
用户权限和组权限
2022-06-12 19:35:00 【Lee Neo】

u+s是如何实现的?
当用户修改自己的密码时,需要修改shadow文件,这个文件普通用户时无法访问的;为什么普通用户可以修改自己的密码?

这是因为passwd文件有u+s权限; 当执行passwd指令时会切换成root身份;

shell 权限的实现过程;

sudo的实现程序:mysu.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main(int argc, char **argv)
{
pid_t pid;
if(argc < 3)
{
fprintf(stderr, "Usage: %s <command> <file>\n", argv[0]);
exit(1);
}
pid = fork();
if(pid < 0)
{
perror("fork()");
exit(1);
}
if(pid == 0)
{
setuid(atoi(argv[1]));
execvp(argv[2], argv+2);
perror("execvp()");
exit(1);
}
wait(NULL);
exit(0);
}
执行时需要:
chown root mysu
chmod u+s mysu
./mysu 0 cat /etc/shadow //以0号用户的身份执行
边栏推荐
- Wechat e-book reading applet graduation design completion works (3) background function
- 模塊八作業
- Original introduction to Jenkins' configuration options
- 设备管理-借还模块界面代码
- Cookie & session & kaptcha verification code
- Méthode de sauvegarde programmée basée sur la base de données distribuée elle - même
- Lua record
- Module 8 operation
- 基于分布式数据库本身的定时备份方法
- 从16页PPT里看懂Jack Dorsey的Web5
猜你喜欢

超级重磅!Apache Hudi多模索引对查询优化高达30倍

Wechat e-book reading applet graduation design work (6) opening defense ppt

ISCC2022

Detailed explanation of yolox network structure

负数取余问题
![[image denoising] image denoising based on anisotropic filtering with matlab code](/img/3d/ee2e36b15b5db2502e43f6945685c5.png)
[image denoising] image denoising based on anisotropic filtering with matlab code

什么是数据驱动

WinCC7.5 SP1调整画面尺寸以适应显示分辨率的方法

【图像去噪】基于各向异性滤波实现图像去噪附matlab代码

Storage system overview
随机推荐
Pyinstaller packaging tutorial packaging resource files
Leetcodesql: count the number of students in each major
Shell 数组和函数
Mysql database experiment I data definition
设备管理-借还模块1
Original publishing practice of pipeline in Jenkins docking with CMDB interface to obtain host list
7:00 tonight | application of PhD debate self supervised learning in Recommendation System
Is it really hopeless to choose electronic engineering and be discouraged?
Analysis report on market demand and investment strategy of China's re guarantee industry 2022-2028
asp. Net using JSON to interact with API data
基于分布式数据库本身的定时备份方法
5G R17标准冻结,主要讲了些啥?
攻防世界(web篇)---supersqli
Cookie & Session & kaptcha验证码
"As a service", the future has come, starting from the present | new mode of it consumption, FOD billing on demand
基于微信电子书阅读小程序毕业设计毕设作品(3)后台功能
5g R17 standard is frozen. What does it say?
Embedded development: 6 necessary skills for firmware engineers
First build green, then build city
Cookie & Session & kaptcha驗證碼