当前位置:网站首页>用户权限和组权限
用户权限和组权限
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号用户的身份执行
边栏推荐
- Implementation of VGA protocol based on FPGA
- Module 8 operation
- VC hacon joint programming genimage3extern writeimage
- 基于微信电子书阅读小程序毕业设计毕设作品(3)后台功能
- Detailed explanation of yolox network structure
- 基于微信电子书阅读小程序毕业设计毕设作品(5)任务书
- Shell 编程正则表达式及元字符
- Wangxuegang room+paging3
- 简单理解防抖函数
- Shell programming regular expressions and metacharacters
猜你喜欢

基于分布式数据库本身的定时备份方法

5g R17 standard is frozen. What does it say?

QT -- how to get the contents of selected cells in qtableview

RT-Thread 模拟器 simulator 搭建 LVGL 的开发调试环境
![[image denoising] image denoising based on regularization with matlab code](/img/d9/74f4d9cdb4bfe157ba781ec8f6a184.png)
[image denoising] image denoising based on regularization with matlab code

基于微信电子书阅读小程序毕业设计毕设作品(2)小程序功能

Dacom G150双模耳机,为爱发声,呵护孩子听力健康成长

YOLOX网络结构详解

7:00 tonight | application of PhD debate self supervised learning in Recommendation System

Leetcodesql: count the number of students in each major
随机推荐
运算器的基本结构
编程工具下载地址
存储体系概述
easycode一键生成插件自定义模板
typescript的装饰器(Decorotor)基本使用
ISCC2022
Report on market demand trends and future strategic planning recommendations of the global and Chinese smart financial solutions industry 2022-2028
vc hacon 联合编程 GenImage3Extern WriteImage
torch 网络模型转换onnx格式,并可视化
asp. Net using JSON to interact with API data
3D object detection
unity websockt一些知识:
Pyinstaller packaging tutorial packaging resource files
META-INF、WEB-INF分别是什么?
Implementation of VGA protocol based on FPGA
Super heavy! Apache Hudi multimode index optimizes queries up to 30 times
模塊八作業
mysql的增删改查,mysql常用命令
RT thread simulator builds lvgl development and debugging environment
Mode of most elements (map, sort, random, Boyer Moore voting method)