This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[solved] starting eggdrop not within its directory

General support and discussion of Eggdrop bots.
Post Reply
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

[solved] starting eggdrop not within its directory

Post by hotrs »

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.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Search the forums as this problem has been discussed previously.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

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)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

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: Select all

    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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

EGG_LANGDIR=/usr/local/eggdrop/language chrootuid /chroot/eggdrop/ eggdrop /usr/local/eggdrop/eggdrop /usr/local/eggdrop/eggdrop.conf
NML_375
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

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
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

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
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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

change "./language" to the full path
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

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
h
hotrs
Voice
Posts: 13
Joined: Tue Apr 03, 2007 2:51 am

Post by hotrs »

Code: Select all

/*
  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 ;).

greets,
hotrs
Post Reply