- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在运行的程序需要 root 权限,因此使用 sudo
运行,但它还需要知道运行它的用户。 getuid
和 geteuid
都返回 root
。如何获取实际用户的用户名(或 uid)?
谢谢!
最佳答案
sudo
提供了一些环境变量来帮助您处理这种情况:
SUDO_UID Set to the user ID of the user who invoked
sudo
SUDO_USER Set to the login of the user who invoked sudo
steveayre 在评论中指出,在某些情况下用户可以设置这些环境变量; sudo(8)
联机帮助页部分包含:
The sudoers policy subjects variables
passed on the command line to the same restrictions as normal
environment variables with one important exception. If the
setenv option is set in sudoers, the command to be run has the
SETENV tag set or the command matched is ALL, the user may set
variables that would otherwise be forbidden. See sudoers(5)
for more information.
因此,当您需要依赖此功能时,请确保不要向用户授予 ALL
命令。
关于c - 如果程序使用 sudo 运行,我如何获得用户的真实 uid?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10272784/
如果满足条件,我如何才能只获取特定记录? 我有代码为 "SELECT a.id, a.text, a.uid, a.time FROM story a INNER JOIN friends b
每当我尝试提取用户的 uid 时,它都会给我电子邮件。有谁知道为什么? var user = firebase.auth().currentUser; if (user != null
我正在为自己的业务编写一个简单的客户数据库(新娘礼服),并尝试实现以下目标: 我尝试过滤掉那些没有“ordered = 1”标志的uid。因此,不应显示来自用户的所有条目,其中至少一个条目具有“ord
我有一张表,UID 是主键。在旧系统中,它不是主键。因此,人们可以向该字段插入数据,但我们不想再这样做了。 在这个表中,我在 UID 2000 和 2005 之间有一个差距(2003 被占用)。我如何
我刚开始使用 Firebase(我正在使用react-redux-firebase,但不确定这是否与这个问题相关)。我在使用这些标准身份验证规则时遇到问题: { "rules": {
警告:我对一般编码和 xcode 非常陌生 运行 Xcode 8.2 无论如何,我已经保存了我的用户身份验证详细信息、电子邮件密码。我将它们保存在 user/currentUser.UID 下,它提供
有人知道吗,如果我从我的应用程序启动 android web-view 窗口,它是否与启动它的应用程序具有相同的 UID。我正在使用三星手机,我认为他们使用的是 Web-Kit 浏览器,但我也想知道使
我有一个正在注册用户的注册表单,如果注册完成,应该重定向到index.html(主页)。 问题:按下提交按钮后,页面刷新并且表单获取重置,不会重定向,除非我按 CTRL + SHIFT + R 然后将
这个问题在这里已经有了答案: SecurityException: caller uid XXXX is different than the authenticator's uid (17 个答案
我正在尝试构建一个基于 PHP 的 Web 软件,但我遇到了一个我不知道解决方案语法的问题。 基本上,我有两个表: +-------------+ +---------------+ | Ce
我有一个 Firebase 表,其中包含任务列表。 任务有一个名为 uid 的字段。 我想获取我传入的 uid == uid 的所有任务。 最佳答案 Firebase 允许您对一组数据进行排序和过滤。
这是一个 set-root-uid 程序 $ls -l -rwsr-sr-x 1 root root 7406 2011-12-13 22:37 ./x* 源代码: int main(void) {
我在 OSX 上使用 emacs 24.5.1 和 mu4e 和 mbsync。我正在与 imac 和笔记本电脑同步,所以可能与前面提到的错误相同 here ,但没有人发布解决方案。 我的具体错误是在
我注意到 access(2) 系统调用使用真实且无效的用户 ID 进行访问控制检查的困难之处。虽然这与 Linux 上的 access(2) 手册页所说的一致,但对我来说仍然没有什么意义......
我需要帮助来了解如何创建数据库系统,以便每个用户都有自己的数据,我想确保当我从我的站点发送数据时,它是用这个顺序保存的(集合名称)/(创建该数据的用户的 uid)/(名称由日期创建的文档#this 我
假设我有一个独特的 VarChar(32) 列。 例如。 13bfa574e23848b68f1b7b5ff6d794e1。 我想在将列转换为 int 时保留它的唯一性。我想我可以将所有字母转换为它们
我想弄清楚如何将我的“数据”数组中的 Firebase UID 字符串与我从 firebase 调用中提取的键相匹配。我需要将“数据”数组中的字符串与“键”相匹配,然后我就可以按我想要的方式操作数据。
如果我使用 imaplib 在收件箱中有此邮件的 UID,如何获取所有 Maill 文件夹中邮件的 UID?如您所知,所有邮件和收件箱中的两个实例中的谷歌商店邮件我想使用 imaplib 将其移动到垃
我正在制作一个控制电话网络状态的应用(在 2G/3G 之间切换)。 出于某种原因,我的应用程序使用 sharedUserId="android.uid.system",但在 Phone 上下文下运行(
我在尝试实现 Sample Sync Adapter 应用程序时收到上述异常。我看过很多与此问题相关的帖子,但没有令人满意的回复。 所以我会记下my solution在这里以防其他人遇到同样的问题。
我是一名优秀的程序员,十分优秀!