Hacking aMule to remove root warning message

Before I start, i'd like to say that be very careful when doing this patch, and understand the security risks of running p2p software under root. Do not use it unless you have a very good reason to, and I won't be held responsible for any damage, confusion, suicides, yadda yadda..
That said, are you irritated that the recent versions of aMule include a check to see if you run it through the root user or not? And that you HAVE to click the button every time, and that it doesn't have a 'yes i understand, but i have my reasons, so please don't warn me again' tick box to make it go away?
I for one have my reasons to run it under root, be them as bizzar as they can be, but still I have them, and for one, to create a script that auto starts and stops amule now is impossible because of this error.
So here is a simple nasty hack get rid of it...
NOTES
For my testing machine, I only have the user root, so I don't care about any other users in there. This patch also follows that.
Users not running Gentoo as their Linux distro can skip steps 1 and 2, and just go straight to step 3 and 4 for editing, and 5b for compiling.
1. Portage Overlay
The first step is to follow this guide in order to get your portage overlay up and running. Follow steps 1 and 2 only. The rest of the steps will be shown below. However, do read the other steps just to get the basic idea of what you'll be doing here.
2. Setting up the ebuild
For this example, I will be using aMule version 2.1.3. The easiest thing to do is to copy the already existing amule/ ebuilds from the original portage, and to edit to suit our needs. So,
immitate the original portage by creating the overlay
cd /usr/local/portage
mkdir net-p2p
cd net-p2p
mkdir amule
copy over the original folder and its subfiles & subfolders
cp -R /usr/portage/net-p2p/amule/* /usr/local/portage/net-p2p/amule/
3. Download the source code
So, let's download the aMule sourcecode , extract it, and change directory into it.
tar xvjf aMule-2.1.3.tar.bz2
cd aMule-2.1.3
4a. Edit aMule manually.
If you're on Gentoo, or if you would like to create a patch, I strongly recommend you skip this step, and move on to step 4b.
The easy way to remove the warning box in aMule is to open src/amule.cpp with your favorite text editor, and search for line #637 that contains the line if (getuid() = 0) { , and replace that equal sign
( = )
with a 'does not equal' sign
( != )
. So you end up with
if (getuid() != 0) {
wxString msg =
...
And then compile your code.
4b. Edit aMule automatically through patching
An even quicker way in the long run is to create a patch.
Why bother going through the code again and again and messing around with it every time you re-download the source code or re-emerge aMule when you can just create a patch file to do it for you? Patching is very easy. Just copy the contents of the patch file below if you do not wish to read all this step, but I recommend that you do. It takes a minute, and it will help later on in linux.
The way I create a patch is by simply making a copy of the file I wish to edit, say for example, test.cpp, and test.cpp.new. I edit the copy (test.cpp.new), save it, and then I can compare it with the original (test.cpp) to create my patch.
The syntax for creating a patch is as follows,
diff -Naru oldfile newfile > myresult.patch
So, edit the file src/amule.cpp as shown above in step 4a, and save the result in a new file, name it amule.cpp.new.
Finally, create the patch file by issuing the following command,
diff -Naru src/amule.cpp src/amule.cpp.new > 2.1.3-no_root_warning.patch
The result will be a patch file called 2.1.3-no_root_warning.patch that contains the following. If you're in a hurry you can skip the above and just copy my patch file i just did, or you can download your own copy from here. Note, i like to include the aMule version in the name of my patch, so that i can distinguish it from other patches for other versions.
--- src/amule.cpp 2006-07-23 22:12:39.000000000 +0100
+++ src/amule.cpp.new 2006-07-23 22:13:04.000000000 +0100
@@ -634,7 +634,7 @@
}
#ifndef __WXMSW__
- if (getuid() = 0) {
+ if (getuid() != 0) {
wxString msg =
wxT("Warning! You are running aMule as root.\n")
wxT("Doing so is not recommended for security reasons,\n")
Copy this patch file into /usr/local/portage/net-p2p/amule/files/
5a. Compiling & Installing - The Gentoo way
For anyone not running Gentoo, skip to step 5b.
So, now we need to update the ebuild to tell it that we have a new patch. Change directory to /usr/local/portage/net-p2p/amule/ and edit the ebuild with your favorite text editor and look for the line src_compile() {,
src_compile() {
local myconf=""
if use gtk ; then
...
Add the following line in there,
src_compile() {
# add no root warning patch
epatch "${FILESDIR}/${PV}-no_root_warning.patch"
local myconf=""
if use gtk ; then
...
save the file, and now you can emerge aMule like you always do. For more information on emerging it, follow the 3rd party ebuild tutorial on using ebuild.
Note: Incase anyone asks, i use the following USE flags for aMule,
"amuled gtk nls remote unicode"
5b. Compiling & Installing - The non Gentoo way
For anyone not running Gentoo, you'll need to compile aMule manually. Follow the installation guide in the aMule wiki. If you're in a hurry, this is how I'd compile,
cd aMule-2.1.3
./configure --with-wx-config=${WX_CONFIG} --enable-amulecmd --enable-amuled --enable-amule-daemon --enable-optimize -enable-amule-gui
make
make install
That's about it. Feel free to comment on the guide, or correct any mistakes i made.



Bookmark this site
Post new comment