egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[solved] starting eggdrop not within its directory

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help
View previous topic :: View next topic  
Author Message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Tue Apr 03, 2007 3:33 am    Post subject: [solved] starting eggdrop not within its directory Reply with quote

Hi *.*.

I try to run eggdrop in a chroot environment with a restricted user account without a shell, therefore I can't execute a shell script to change the current directory.

I try to change all relative paths to absolute paths, f.e.

modules/

to

/usr/local/eggdrop/modules/

which seems to work, but I can't find any variable for the language directory and eggdrop nag about missing language files.

Is there a chance to change the language files directory? Or perhaps I can change the current directory with a tcl statement at the begining of the conf file?


thx,
hotrs


Last edited by hotrs on Thu Apr 05, 2007 3:10 am; edited 1 time in total
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Apr 03, 2007 8:49 pm    Post subject: Reply with quote

Search the forums as this problem has been discussed previously.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Apr 04, 2007 12:32 am    Post subject: Reply with quote

In a chroot environment, your chrooted dir is / so your absolute path should be /modules/ and so on. Another possibility would be ~/modules/ (~ is shorthand for /your/home/dir/ )

Edit: I might've misunderstood the question, after thinking about it for a minute, you should be able to resolve the problem with symlinks (ln -s /path/to/languagefiles/ /chrooted/dir/language)
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 04, 2007 7:38 am    Post subject: Reply with quote

As I recall, the only way of relocating language-files is either to edit the source (LANGDIR macro in src/eggdrop.h), or use the environment variable EGG_LANGDIR
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Wed Apr 04, 2007 8:02 am    Post subject: Reply with quote

nml375 wrote:
As I recall, the only way of relocating language-files is either to edit the source (LANGDIR macro in src/eggdrop.h), or use the environment variable EGG_LANGDIR


Thx for your answer. I allready have done a search BEFORE I post my question - but perhaps I missed the right key words.

I don't want to change the directory structure (f.e. creating links direct unter /chroot/dir/) and I can't execute a shell script.

Is it right that there is no chance for me to use EGG_LANGDIR because of the restricted user account without a home directory and without a shell, too?


Seems to me the only solution is to fix the source or write a little tool which change the current directory and starts eggdrop.

greets,
hotrs
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 04, 2007 8:07 am    Post subject: Reply with quote

Well, you could access the environment variables from within tcl using the special tcl array-variable "env": ie. setting env(EGG_LANGDIR) to a new value. I'm not sure however if eggdrop has'nt already tried to load languagefiles when the main config-file is read.

There are a few other tricks that could be tried aswell, depending on how you start your eggie...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Wed Apr 04, 2007 8:14 am    Post subject: Reply with quote

nml375 wrote:

There are a few other tricks that could be tried aswell, depending on how you start your eggie...


I use something like this:

Code:

    chrootuid /chroot/eggdrop/ eggdrop /usr/local/eggdrop/eggdrop /usr/local/eggdrop/eggdrop.conf


(eggdrop was installed in /chroot/eggdrop/usr/local/eggdrop)

If I can use a special TCL cmd in the conf file to modify the environment, perhaps I can change the current directory using another TCL cmd?

greets,
hotrs
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Apr 04, 2007 8:59 am    Post subject: Reply with quote

Sure, you could always use the "cd" command to change current directory.

I'm not too familiar with chrootuid. I don't suppose your eggdrop inherits the environment from where chrootuid were run?
Ie. doing something like this:
Code:
EGG_LANGDIR=/usr/local/eggdrop/language chrootuid /chroot/eggdrop/ eggdrop /usr/local/eggdrop/eggdrop /usr/local/eggdrop/eggdrop.conf

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Wed Apr 04, 2007 9:15 am    Post subject: Reply with quote

nml375 wrote:
Sure, you could always use the "cd" command to change current directory.

I'm not too familiar with chrootuid. I don't suppose your eggdrop inherits the environment from where chrootuid were run?


I will test both, this evening. And I will post the results here.
Thx so far.

greets,
hotrs
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Wed Apr 04, 2007 3:40 pm    Post subject: Reply with quote

Both solutions work. I can start chrootuid with a manipulated EGG_LANGDIR environment and I can put a "cd /usr/local/eggdrop" at the beginning of eggdrop.conf.

The first solution could be a problem for other scripts if they use relative paths without a way to set them - I have to test chanstats and moxxquiz. The second one has the problem that the first messages from eggdrop a shorten to "MSG XYZ", but that doesn't bother me mutch.

If I found some time at the weekend I will write the little start tool.

greets,
hotrs
Back to top
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Wed Apr 04, 2007 4:21 pm    Post subject: Reply with quote

you could also edit src/eggdrop.h before compile:
#define LANGDIR "./language" /* language file directory */

change "./language" to the full path
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Thu Apr 05, 2007 2:48 am    Post subject: Reply with quote

DragnLord wrote:
you could also edit src/eggdrop.h before compile:


Yes, this was allready mentioned by nml375, but I want to avoid changing the source. And it doesn't solve the problems with other scripts using relative paths.

greets,
hotrs
Back to top
View user's profile Send private message
hotrs
Voice


Joined: 03 Apr 2007
Posts: 13

PostPosted: Mon Apr 09, 2007 10:06 am    Post subject: Reply with quote

Code:

/*
  cdandexec.c

  change dir and execute
  usage: cdandexec dir cmd [arg]

  Version 1.0
 
  (c) 2007 Björn Schreiber
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
 
  // check argv
  if (argc < 3) {
   printf("usage: %s dir cmd [arg]\n", argv[0]);
   return EXIT_FAILURE;
  }

  // chdir
  if (chdir(argv[1]) != 0) {
    perror("error changing dir");
    return EXIT_FAILURE;
  }

  // execute
  if (execv(argv[2], &argv[2]) != 0) {
    perror("error executing cmd");
    return EXIT_FAILURE;
  } else
    return EXIT_SUCCESS;
}



This is the little tool I use to start eggdrop in a chroot environment. Perhaps somebody find it useful, so I post it here.

I'm not a C/C++ programmer, so comments are welcome Wink.

greets,
hotrs
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Eggdrop Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber