GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 添加su设置身份代码 · code699/SKRoot-linuxKernelRoot@07e078b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • su
    • su.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎su/su.cpp‎

Copy file name to clipboardExpand all lines: su/su.cpp
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ namespace {
2020
return val;
2121
}
2222

23+
// Set effective uid back to root, otherwise setres[ug]id will fail if uid isn't root
24+
void set_identity(unsigned uid) {
25+
if (seteuid(0)) {
26+
TRACE("seteuid (root)");
27+
}
28+
if (setresgid(uid, uid, uid)) {
29+
TRACE("setresgid (%u)", uid);
30+
}
31+
if (setresuid(uid, uid, uid)) {
32+
TRACE("setresuid (%u)", uid);
33+
}
34+
}
2335
}
2436

2537
void usage(int status) {
@@ -155,6 +167,10 @@ int su_client_main(int argc, char* argv[]) {
155167
new_argv[1] = "-c";
156168
new_argv[2] = su_req.command.data();
157169
}
170+
171+
// If you need it, you can unblock this line of code yourself
172+
//set_identity(su_req.uid);
173+
158174
execvp(su_req.shell.data(), (char**)new_argv);
159175
} else {
160176
wait(NULL);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.