ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i wrote a shell script and was able to compile it using SHC. after that i copied it to the /bin folder and tried running it as a normal user, but i keep getting the error
" operation not permitted
killed "
i tried changing the permissions. but it doesn't work. it only works with sudo. there must be another way. otherwise it won't be linux right?
You can configure sudo by "visudo" command, first read manual of course, otherwise you lock self. By the way, can you tell which command from your script need root access and what your script do?
well i tried using visudo. here is my /etc/sudoers file
Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
User_Alias USERS = anurup
# Cmnd alias specification
Cmnd_Alias CUSTOM_CMDS = /bin/resetproxy, /bin/nautcurrent, /bin/createbin, /bin/shc
# User privilege specification
root ALL=(ALL) ALL
# Allow members of group sudo to execute any command
# (Note that later entries override this, so you might need to move
# it further down)
%sudo ALL=(ALL) ALL
#
#includedir /etc/sudoers.d
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
do i have to add anything else to this file? well one example is i created an auto login script for my network connection
i want to run that as a command. but i need sudo all the time. is there any other way?
i wrote a shell script and was able to compile it using SHC. after that i copied it to the /bin folder and tried running it as a normal user, but i keep getting the error
" operation not permitted
killed "
i tried changing the permissions. but it doesn't work. it only works with sudo. there must be another way. otherwise it won't be linux right?
Um, it only works with sudo? Do you know exactly what operation is "not permitted" otherwise? If you wrote the script, and you don't know what it is in your script that's triggering this message, the worst thing you can do is just say, "oh, well", and run the script under sudo. That would mean using root privileges for doing something that you don't know about. Highly dangerous.
Figure out exactly what operation isn't permitted, first. Don't mess with sudoers, either, until you've answered this question.
well ok i'm at fault there .but let me tell you something .its the same for any script that i write. there is one script which just opens the nautilus browser with the current working directory. is that dangerous?
You must use NOPASWWD if you want to not using passwords during sudo, but wje_lq has right saying that better is to find which command from your script need root access. Otherwise you will create security hole in your system.
In your example - opening nautilus with sudo means that you (or anybody who run this script) will get full access to every file in your system.
i don't think its the problem with my script . i think its the problem with the shc program the executable file it generates cannot be executed without sudo
To be sure. Run this script before compilation as normal user and check if you have no that error. So we will be known if the script generate error or shc.
i wrote a shell script and was able to compile it using SHC. after that i copied it to the /bin folder and tried running it as a normal user, but i keep getting the error
" operation not permitted
killed "
i tried changing the permissions. but it doesn't work. it only works with sudo. there must be another way. otherwise it won't be linux right?
Is it the compiled script that doesn't run?
What are the permissions of the program itself?
If a program can't open a file, one way of debugging is to launch the program using strace. It will list the system calls the program makes. Pay attention to the open calls.
What your compiled script does, could be performed simply modifying the properties of the icon. Change the command argument from %u to the url you want it to start with. Do this on a copy of the icon.
i wrote a shell script and was able to compile it using SHC. after that i copied it to the /bin folder and tried running it as a normal user, but i keep getting the error
" operation not permitted
killed "
i tried changing the permissions. but it doesn't work. it only works with sudo. there must be another way. otherwise it won't be linux right?
I've also encountered this problem with shc-3.8.9 which is installed on Ubuntu 12.04. But the encrypted shell script only works with sudo, too. Then I saw the shc.html file, it shows the following words:
Compile a script which can be run on other systems with the trace option enabled:
example% shc -v -r -T -f myscript
I followed the example command, and my encrypted shell script works without sudo.
well i tried using visudo. here is my /etc/sudoers file
If you are going to grant sudo access, (especially without requiring a password) then it is best to to grant access only to those programs that are absolutely necessary.
For example:
Code:
##
## User privilege specification
##
root ALL=(ALL) ALL
anurupr ALL=(ALL) NOPASSWD: /path/to/program1, /path/to/program2, /path/to/program3
This can also be used for a group.
I use this method to allow me to run shutdown without logging in as root (I use fluxbox).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.