su

exec(“su”) permission denied?

与世无争的帅哥 提交于 2021-02-08 08:27:51
问题 when I use this code Runtime.getRuntime().exec("su"). and listen to the ErrorStream it gives me back: Permission denied. However SuperUser successfully grants permissions. Any Ideas? 回答1: You need to add to your AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/> 回答2: My ROM was messed up. I had to reinstall it. Adding a permission should NOT help. Edit: SuperUser is now giving warning if you don't define the permission, how ever it will still grant su.

exec(“su”) permission denied?

99封情书 提交于 2021-02-08 08:27:27
问题 when I use this code Runtime.getRuntime().exec("su"). and listen to the ErrorStream it gives me back: Permission denied. However SuperUser successfully grants permissions. Any Ideas? 回答1: You need to add to your AndroidManifest.xml <uses-permission android:name="android.permission.ACCESS_SUPERUSER"/> 回答2: My ROM was messed up. I had to reinstall it. Adding a permission should NOT help. Edit: SuperUser is now giving warning if you don't define the permission, how ever it will still grant su.

Getting “must be run from a terminal” when switching to root user using Paramiko module in Python

ぐ巨炮叔叔 提交于 2021-02-07 20:33:26
问题 I am trying to automate a task through a Python script. The idea is to login as a regular user and then send a su command and switch to the root account. The reason I can't directly login as root is that SSHD doesn't allow root logins. Here's what I have: ip='192.168.105.8' port=22 username='xyz' password='abc' ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(ip,port,username,password) print ("SSH connection established") stdin,stdout,stderr=ssh

Linux C programming execute as user

孤人 提交于 2021-02-06 08:51:14
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

℡╲_俬逩灬. 提交于 2021-02-06 08:50:23
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

我们两清 提交于 2021-02-06 08:50:20
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Linux C programming execute as user

走远了吗. 提交于 2021-02-06 08:50:17
问题 I have an program which I run as root. I would like the program to execute another application as a normal user. I tried setgid() and it works, but I can't then go back to root or another user. The program for the time being is very simple; #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char *argv[] ) { if ( argc != 2) { printf("usage: %s command\n",argv[0]); exit(1); } setgid(100); setuid(1000); putenv("HOME=/home/caroline"); putenv("DISPLAY=:0"); system(argv[1

Execute Root Commands and read output Xamarin

為{幸葍}努か 提交于 2021-01-04 05:35:30
问题 I can't read the file from the root directory. How to do it? I use the command for reading Java.Lang.Process suProcess = Java.Lang.Runtime.GetRuntime().Exec(new string[] { "su", "-c", "cat /data/misc/vpn/state" }); but how do I get an answer? 回答1: The Java.Lang.Process class has some interesting Streams you will need to read from. InputStream and ErrorStream . First of all, after you have created your process, you will need to wait for it. This can be done nicely with .WaitForAsync() . This

sudo,su,passwd,chsh命令详解

对着背影说爱祢 提交于 2020-12-16 10:44:08
sudo意思就是super-user do,让当前用户暂时以管理员的身份root来执行这条命令。 su是用来改变当前用户。 su root,就是将当前用户切换为roo。用了su root之后,下面所有的命令就可以不用打sudo了,因为当前用户已经是管理员root了。 root 用户为根用户,也就是 系统管理员。root拥有全部权限。 su [用户名] 切换到其它用户,默认切换到root用户。提示密码为将切换用户密码。可选参数: -f 快速切换,忽略配置文件 -l 重新登录 -p 不更改环境变量 -c <命令> 切换后执行命令,并退出切换 sudo [命令] 以其它用户的身份执行命令,默认以root的身份执行。提示密码为当前用户密码. 可选参数: -s 切换为root shell -i 切换为root shell,并初始化 -u <用户名|UID> 执行命令的身份 -l 显示自己的权限 passwd [用户名] 设定用户密码 . 可选参数: -d 清除密码 -l 锁定用户 -e 使密码过期,在下次登录时更改密码 -S 显示密码认证信息 -x <天数> 密码过期,最大使用时间-n <天数> 冻结密码,最小使用时间-s 更改登录Shell-f 更改用户信息 chsh [-s <Shell>] [用户名] 更改登录Shell 补充: 1.sudo的缺省配置 默 认时, Ubuntu为

linux使用su切换用户提示 Authentication failure的解决方法

馋奶兔 提交于 2020-04-21 08:29:24
刚刚安装的虚拟机,使用的ubtun系统,进如操作系统后,简单地尝试了一下,发现无法使用shutdown命令进行关机,并且无法进行su命令,提示 Authentication failure 这个问题产生的原因是由于ubtun系统默认是没有激活root用户的,需要我们手工进行操作,在命令行界面下,或者在终端中输入如下命令: sudo passwd Password:你当前的密码 Enter new UNIX password:这个是root的密码 Retype new UNIX password:重复root的密码 然后会提示成功的信息。 在说明一点,使用su和sudo是有区别的,使用su切换用户需要输入所切换到的用户的密码,而使用sudo则是当前用户的密码。 来源: oschina 链接: https://my.oschina.net/u/1773287/blog/494989