Comments, Code and Qt. Some words about the wonderful world of software engineering

13Feb/123

‘sudo ./script.sh: command not found’ on Ubuntu

Posted by kypeli

I am pretty sure I could run my script last week, but I cannot anymore today. kypeli@ubuntu:~$ sudo ./myscript.sh [sudo] password for kypeli: sudo: ./myscript: command not found Obviously this was very strange to me because the script was in the current working directory, all permissions looked fine and I could run the script just fine without sudo, which indicated that the shebang was ok. kypeli@ubuntu:~$ ls -la ./script.sh -rwxr-xr-x 1 root root 568 2012-02-13 05:49 ./script.sh kypeli@ubuntu:~$ ./script.sh Usage: ./script.sh [foobar] Give 'foobar' to do Baz So what has happened? Apparently Ubuntu changed something in some update (I am still to verify this) which prevents me from running scripts as sudoer from other than sudo compile time predefined paths. You can verify this by looking at the flags that were used to compile sudo and look for the --with-secure-path option. sudo will not run any script (or command for that matter) outside of these paths. Including . kypeli@ubuntu:~$ cat /usr/share/doc/sudo/OPTIONS ... --with-secure-path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin" Give a reasonable default path for commands run as root via sudo. Well - this was a bit annoying to me for two reasons. I am pretty sure this worked for me last week on my Ubuntu, but suddenly it doesn't work anymore. And secondly, I am not running any public server and I want to run my own scripts with root privileges (why I want to do that is a different topic :)) if I so choose. I must stress that I can see the reasons for doing this and security is always a trade off between security and usability. I would not do this on any public server, but for Ubuntu to not allow me to run my own commands as root is a bit annoying. Luckily I found this tip from Björn Wijers' blog: http://www.burobjorn.nl/blog/2012/01/04/fix-sudo-and-path-environment-variable-on-ubuntu/ Update: Seem Björn's blog is down, so I'll post the solution here. Put the following line to your $HOME/.bashrc file:
alias sudo='sudo env PATH=$PATH $@'
And the run source $HOME/.bashrc (this will not be necessary on subsequent boots or starts of the terminal). You should again be bale to run your scripts with sudo. This will enable the fix only for me, as I put the alias in my .bashrc file, so it's not even a terrible security risk. And that's fine. I would also like to thank @anidel for pointing out initially this possibility.

Technorati Tags: , , , , , ,

7Apr/101

QtOpenCL tested on my old machine

Posted by kypeli

Qt Labs posted today an interesting blog post about OpenCL and how Qt will help developers to make OpenCL easier for them. OpenCL is an open standard and a framework developed by nVidia, Apple and ATI that let's programmer run a piece of code on the GPU (or in parallel simultaneously on the CPU too). The power of OpenCL comes from the fact that our GPUs are much more powerful than the normal CPUs and they are massively optimized to run code in parallel. By offloading the CPU from heavy calculations and by running the calculations in parallel on the GPU, we can achieve some very impressive performance boosts. I'll present the results on my machine below. QtOpenCL is Qt's way to help us with OpenCL. It will, according to the blog post
The QtOpenCL library wraps the OpenCL 1.0 API in a Qt-style API.  It takes the pain out of OpenCL initialization, program compilation, and kernel execution.  It also provides convenience functions for interfacing to existing Qt facilities such as QImage and QtOpenGL.

Technorati Tags: , , , ,