LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-11-2005, 09:36 PM   #1
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Rep: Reputation: 0
Executing an ELF 32 bit on an Apache server running Linux


Hello all,
Please excuse my lack of knowledge in the Apache/Linux area, I'm trying to get this.

Problem: Website made up of file type:
"ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped" sits on one server and runs fine, all file extensions are .rcc
I attempt to copy the website and move to another Apache/Linux server, and I can only see the compiled code.
For instance index.rcc looks great on current server, but I copy the entire site folder, upload it to new server, and index.rcc looks like a bunch of squares, circles, lines, and little text.

The closest I feel like I've gotten to a step in the right direction is:
"About:
RC is a dialect of C that adds safe, region-based memory management to C. Region-based memory management allocates objects in a program-specified region. Objects cannot be freed individually; instead regions are deleted with all their contained objects. RC is safe, since for each region, r, it maintains a reference count of the number of external pointers to objects in r (i.e. of pointers not stored within r). Deleting a region with a non-zero reference count causes a runtime error (abort). RC's compiler, rcc, is based on gcc."
as found at freshmeat.net/projects/rcc/
But I could be lightyears away on this one.

Access to the source isn't possible(relationship between my client and developer went bad, unfortunately.)

I greatly appreciate any help and moderators, if you feel like this post would be better answered in another forum, please move it.

Thanks much
Chris
 
Old 10-12-2005, 08:54 AM   #2
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Hopefully getting closer

I'm back, and I hope I have gotten a little closer to solving this.
From what I can tell, an ELF file (Extendable and Linkable Format) begins as a C/C++
This is taken verbatim from developers.sun.com/solaris/articles/elf.html


"Executable and Linkable Format is a portable object file format supported by most UNIX® vendors. It is the dominant file format for UNIX executables, object files and libraries. ELF was originally developed and published by UNIX System Laboratories, and defines the format of an ELF object file.

ELF helps developers by providing a set of binary interface definitions that are cross-platform, and by making it easier for tool vendors to port to multiple platforms. Having a standard object file format also makes porting of object-manipulating programs easier. Compilers, debuggers, and linkers are some examples of tools that use the ELF format.
ELF

The ELF specification describes three kinds of object files.

1. Relocatable files - Hold code and data suitable for linking with other object files
2. Executable files - Hold code and data that can be executed on the target operating system
3. Shared object files - Hold relocatable data that can be statically and dynamically shared with other shared objects

Relocatable files are also called as object files (.o files). They are generated by the compiler during compilation of a source file (such as a C or C++ file). These object files are then processed by the linker to produce either an ELF executable or shared objects (also called shared libraries). Executable ELF objects can then be executed by the user. A shared library is a collection of routines that different object files or executables can share. Shared libraries are made up of several object files with position independent code (PIC). "

Now if I get this correctly, ELF is just the result of a compiled C/C++ file? If this is true, then would it also be true that the /usr/bin would have to contain some sort of file allowing for the execution of these compiled files?
Okay, I can look through the current server /user/bin and see these files
c++
c++decl
c++filt
Do these relate in any way to the execution of these ELF files.
There are many more of these in the /usr/bin/ such as a /gcc which I understand to be a compiler.

I opened the 'c++' file and found this snippet
'exec startfile /usr/lib/gcc-lib/'

I'm really not sure if any of this will help you all help me, but I certainly hope so. If you can't tell, I'm trying very hard to find a way out of this, but I have to get some kind of reassurance on my 'theories' before taking any actual steps.

Thanks again.
Chris
 
Old 10-12-2005, 09:19 AM   #3
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
Try to put the file in you apache cgi-bin directory, make it executable (chmod +x index.rcc) and access it with your browser like this: http://newserver/cgi-bin/index.rcc
 
Old 10-12-2005, 09:58 AM   #4
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Hi,
Thanks for your reply.

I did what you said, and when I try to access it I get an Internal Server Error with this line
The server encountered an internal error or misconfiguration and was unable to complete your request.

and this line
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Now, I have had that problem when using a Perl script(FormMail from MSA I think), but if I remember correctly, I changed the permissions and it fixed the problem. The new site uses Cpanel and I changed the permissions to 755 before trying to access it via /cgi-bin/index.rcc. So does this mean the server just needs to be configured to execute a file such as this?

Thanks much for your attention,

Chris
 
Old 10-12-2005, 12:54 PM   #5
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Is this considered cgi?

Ok, if this is considered cgi, and I can understand this correctly
http://httpd.apache.org/docs/2.0/howto/cgi.html

Then the problem is the Apache I'm using just isn't configured to handle it. Seems simple enough (half-kidding)

I would assume I need to configure Apache to handle this program outside of the cgi directory, so using ScriptAlias wouldn't be enough. I would need to activate the handler using AddHandler or SetHandler (which one i'm not sure of yet) and specify ExecCGI in the Options directive.

So, this snippet, taken from the above mentioned site
<Directory /home/*/public_html>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
edited to this
<Directory */public_html> ## because files reside in /public_html
Options +ExecCGI
AddHandler cgi-script .rcc
</Directory>
might make it work?

Just to clear up any confusion, this is part question, part need for clarification. Sorry about the newb-ness.

Chris

And, if all this is in the right direction, I should be able to comb the current server and find a similar directive, so that's what I'm off to do.

Last edited by chrisrock79; 10-12-2005 at 12:57 PM.
 
Old 10-12-2005, 01:20 PM   #6
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
What happens if you run the file from command line:
Code:
./index.rcc
If you can run it (even with errors) then apache can run it also. I know for sure it can run programs written in C.
You can take a look at the apache error_log to see if you find anything about the internal server error.
If you use the ScriptAlias directive you don't need the UserDir. Or else:
Quote:
<Directory */public_html> ## because files reside in /public_html
should be:
Code:
 <Directory /home/*/public_html> ## because files reside in /public_html
 
Old 10-12-2005, 02:42 PM   #7
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Keeping in mind, I'm very new at this stuff :
From webmin on current server I go to the 'command shell' and type in
Code:
./index.rcc
This returns
Code:
> ./index.rcc
sh: line 1: ./index.rcc: No such file or directory
The new server is not under my control, except cpanel. They are trying to help me, but they seem just as lost as I do, so I'm trying to help them help me.

When I try to access file from web browser in a directory outside of cgi-bin, I get no error, just a bunch of un-readable code.
When I try to access file located in cgi-bin, I get the 500 internal server error and the error log gives this:
Code:
[Wed Oct 12 12:31:48 2005] [error] [client **.***.2*.9*] File does not exist: /home/bbd/public_html/500.shtml
[Wed Oct 12 12:31:48 2005] [error] [client **.***.**.9*] Premature end of script headers: /home/bbd/public_html/cgi-bin/index.rcc
I assume the first one is looking in .htaccess for my error handling page which doesn't exist.
I assumed I couldn't use the ScriptAlias directive because the files will be located outside of the cgi-bin. I'm thinking I need to tell something that .rcc needs to be ran as a cgi script, then whenever a .rcc file is encountered, the server automatically handles it that way. Or this could just be nonsense. I usually love trial and error.

I really appreciate your help, I have a feeling you want me to run ./index.rcc from the new server and get the output, but I can't see where I have access to a command line.
Let me know what I need to do to give you any information you feel will help.

Thanks for your ongoing support,

Chris

Last edited by chrisrock79; 10-12-2005 at 02:43 PM.
 
Old 10-12-2005, 09:18 PM   #8
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Yet more hopefully useful infomation

I'm back, and I'm learning all kinds of things. I found this information which I hope is useful. It is from the current server and it was found using
Code:
readelf -a
Code:
 ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x804bff4
  Start of program headers:          52 (bytes into file)
  Start of section headers:          3606840 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         37
  Section header string table index: 34
It occurred to me I could build this site over in a week, but I'm warm
If any one could let me know what I need to do to make the new server execute a file of this type, I'd really appreciate.

Thanks, Chris

And don't worry, I'll keep you UTD
 
Old 10-12-2005, 09:48 PM   #9
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
And, if GNU binutils are on the current server, would they have to be on the new server as well(maybe the program was assembled and compiled using binutils)?

Chris
 
Old 10-13-2005, 02:39 AM   #10
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,908

Rep: Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326Reputation: 1326
The error "Premature end of script headers: /home/bbd/public_html/cgi-bin/index.rcc" means that your file does not produce valid html headers. Are you sure that you can run it directly from apache? What is the way you use this application till now? You can try also the other .rcc files to see what happens. Perhaps you need some other file(s) to exist on the server, so to be able to run *.rcc (see also the error: "sh: line 1: ./index.rcc: No such file or directory").
Since you have access to the current server take a look at httpd.conf (and perhaps the other *.conf files) to see if you have to enable other thing, such as SSI or "AddType application/? .rcc"
 
Old 10-13-2005, 12:48 PM   #11
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Right now, the file is accessed by going to a website url, index.rcc is performing like index.html. Going to www.domain.com = www.domain.com/index.rcc . I did try another .rcc file, I put it in the cgi-bin, changed the permissions, and same result. My host did AddHandler directive but that didn't change anything either. I'm off to look at the *.conf files now.

Thanks much
Chris
 
Old 10-13-2005, 01:00 PM   #12
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Oh, httpd.conf is a big file. Is there anything in particular I should be looking for?

Thanks,
Chris
 
Old 10-13-2005, 01:12 PM   #13
chrisrock79
LQ Newbie
 
Registered: Sep 2005
Posts: 14

Original Poster
Rep: Reputation: 0
Ok scratch that prevous post, I think.
I'm reading through it and, because of my intense reading over the past couple of days, I see something familiar:
Code:
<Directory "/home/web/vvvvv">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory "/home/web/vvvv">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory "/home/web/vvvv">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<Directory "/home/web/vv/data">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
<Directory "/home/web/vvv/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
The ExecCGI is what I see as important, it means that CGI scripts can be executed in this directory. Which, to me is saying, 'This file is a CGI script, and just because it doesn't sit in the folder defined in the ScriptALias directive, we should still let it execute'

Okay, I'm going back and you know I'll keep you all updated, don't give up on me bathory, I'll get it.

Chris


Edit, found this line:"DirectoryIndex index.rcc index.html index.html.var"
I'm assuming that is why index.rcc can respond the same as an index.html.

Ha, and I found this
AddHandler cgi-script .pl .rcc , which needs execCGI to perform.(The .rcc is what got me all happy and stuff)

I'd be willing to bet, with this addhandler, and the Options directive correctly done on the public_html/ directory, and the DirectoryIndex directive, this script will be running.

Last edited by chrisrock79; 10-13-2005 at 01:26 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing a 64 bit Linux and running 32 binaries? hal9000hal Linux - Newbie 0 01-31-2005 11:05 AM
Opening or Executing files in linux from a windows Server rmarvin Linux - Networking 7 01-17-2005 10:32 AM
ELF 32-bit LSB executable how to run vinsky2002 Linux - Software 1 01-12-2005 02:07 AM
CGI File Not Executing on Apache Server kaplan71 Linux - Software 2 10-21-2004 07:12 AM
executing script via webpage through apache server feetyouwell Linux - Software 7 02-08-2004 03:23 PM


All times are GMT -5. The time now is 04:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration