当前位置:网站首页>用户权限和组权限
用户权限和组权限
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号用户的身份执行
边栏推荐
- The execution results of i+=2 and i++ i++ under synchronized are different
- Market development planning and investment prospect analysis report of Chinese government investment and financing platform 2022-2027
- Blue Bridge Cup basic-14 VIP question time conversion
- leetcodeSQL:602. Friend application II: who has the most friends
- API call display, detailed API of Taobao, tmall and pinduoduo commodity pages, and return of APP side original data parameters
- Wechat e-book reading applet graduation design completion works (8) graduation design thesis template
- In 2021, the global fire pump drive power revenue is about $381million, and it is expected to reach $489.3 million in 2028
- Report on the development status of China's asset appraisal industry and suggestions for future strategic planning 2022-2027
- [digital ic/fpga] data accumulation output
- Dacom G150双模耳机,为爱发声,呵护孩子听力健康成长
猜你喜欢

vc hacon 聯合編程 GenImage3Extern WriteImage

Detailed explanation of IO flow basic knowledge -- file and IO flow principle

Negative remainder problem
![[digital ic/fpga] data accumulation output](/img/58/8d10e41a7bc837feba677f1e0b1ceb.png)
[digital ic/fpga] data accumulation output

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

New product launch

Reading small program graduation design based on wechat e-book (5) assignment

Shell arrays and functions

Basic structure of arithmetic unit

Implementation of VGA protocol based on FPGA
随机推荐
Equipment management - borrowing / returning module interface code
Software usage of Tencent cloud TDP virt viewer win client
7:00 tonight | application of PhD debate self supervised learning in Recommendation System
基于微信电子书阅读小程序毕业设计毕设作品(8)毕业设计论文模板
ThansmittableThreadLocal详解
负数取余问题
Report on market demand trends and future strategic planning recommendations of the global and Chinese smart financial solutions industry 2022-2028
[5gc] Introduction to three SSC (session and service continuity) modes
A journey of database full SQL analysis and audit system performance optimization
Wechat e-book reading applet graduation design completion works (3) background function
Mysql database experiment I data definition
Business opportunities with an annual increase of 3billion - non cage eggs or a new blue ocean for export to ASEAN
【5GC】三种SSC(Session and Service Continuity)模式介绍
[SQL] MySQL query statement execution sequence analysis
YOLOX网络结构详解
Php+flash large file breakpoint continuation function sharing
VC hacon joint programming genimage3extern writeimage
API call display, detailed API of Taobao, tmall and pinduoduo commodity pages, and return of APP side original data parameters
Equipment management - borrowing and returning module 1
review.js ppt数学公式无法显示