Re: [PATCH 1/2 v2] ash: move code to allow setting $HOME in /etc/profile

2013-03-15 Thread Stefan Hellermann
>> move HISTFILE=$HOME/.ash_history below reading /etc/profile,
>> so that /etc/profile can set $HOME. HOME can be unset when
>> directly invoking ash --login from init without going through
>> getty.
>
> Does hush also suffer from this?
>

No, it already reads /etc/profile before setting HISTFILE. But it
doesn't read $HOME/.profile at all, should I send a patch to bring it
in line with ash and other shells?

Regards,
Stefan Hellermann
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 1/2 v2] ash: move code to allow setting $HOME in /etc/profile

2013-03-03 Thread Stefan Hellermann
move HISTFILE=$HOME/.ash_history below reading /etc/profile,
so that /etc/profile can set $HOME. HOME can be unset when
directly invoking ash --login from init without going through
getty.

The lines
+setvar("HISTFILE", hp, 0);
+free(hp);
+hp = lookupvar("HISTFILE");
are added to not leak memory, if this is not important we can
remove the last two lines and save a lookupvar.

Signed-off-by: Stefan Hellermann 

---
Version 2:
- Don't fallback to /.ash_history if $HOME is unset

diff --git a/shell/ash.c b/shell/ash.c
index 0b5111a..f424701 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13191,19 +13191,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
setstackmark(&smark);
procargs(argv);
 
-#if ENABLE_FEATURE_EDITING_SAVEHISTORY
-   if (iflag) {
-   const char *hp = lookupvar("HISTFILE");
-   if (!hp) {
-   hp = lookupvar("HOME");
-   if (hp) {
-   char *defhp = concat_path_file(hp, 
".ash_history");
-   setvar("HISTFILE", defhp, 0);
-   free(defhp);
-   }
-   }
-   }
-#endif
if (argv[0] && argv[0][0] == '-')
isloginsh = 1;
if (isloginsh) {
@@ -13243,6 +13230,15 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
 #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
const char *hp = lookupvar("HISTFILE");
+   if (!hp) {
+   hp = lookupvar("HOME");
+   if(hp) {
+   hp = concat_path_file(hp, 
".ash_history");
+   setvar("HISTFILE", hp, 0);
+   free(hp);
+   hp = lookupvar("HISTFILE");
+   }
+   }
if (hp)
line_input_state->hist_file = hp;
 # if ENABLE_FEATURE_SH_HISTFILESIZE
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 2/2 v2] ash: read $HOME/.profile instead of $(pwd)/.profile

2013-03-03 Thread Stefan Hellermann
ash --login should read ~/.profile instead of .profile in the current
directory. I noticed it while trying to figure out why /root/.profile
is only read sometimes.

Signed-off-by: Stefan Hellermann 

---
Version 2:
- only read .profile if $HOME is set, otherwise skip

diff --git a/shell/ash.c b/shell/ash.c
index 7c91a77..6823514 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13198,7 +13198,13 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
read_profile("/etc/profile");
  state1:
state = 2;
-   read_profile(".profile");
+
+   const char *hp = lookupvar("HOME");
+   if(hp) {
+   hp = concat_path_file(hp, ".profile");
+   read_profile(hp);
+   free(hp);
+   }
}
  state2:
state = 3;
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: [PATCH 2/2] ash: read $HOME/.profile instead of $(pwd)/.profile

2013-03-03 Thread Stefan Hellermann
>> --- a/shell/ash.c
>> +++ b/shell/ash.c
>> @@ -13198,7 +13198,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
>>  read_profile("/etc/profile");
>>   state1:
>>  state = 2;
>> -read_profile(".profile");
>> +const char *hp = lookupvar("HOME");
>> +hp = concat_path_file(hp, ".profile");
>> +read_profile(hp);
>> +free(hp);
> This is a good point :)
>
> NTL the code (reading histfile) assumed that HOME can be empty.
> can you save drop this assumption here ?

concat_path_file already special cases hp=NULL, in this case the output
is "/.profile". We have 3 options if HOME is empty:

1) don't read .profile at all
2) read .profile in the current $(pwd)  (before patch)
3) read /.profile   (after patch)

I think option 1) is even better, maybe with a warning.
If there is no HOME, don't try to read the profile from
a random folder.
I will send a new patch.
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 2/2] ash: read $HOME/.profile instead of $(pwd)/.profile

2013-03-02 Thread Stefan Hellermann
ash --login should read ~/.profile instead of .profile in the current
directory. I noticed it while trying to figure out why /root/.profile
is only read sometimes.

Signed-off-by: Stefan Hellermann 

diff --git a/shell/ash.c b/shell/ash.c
index 7c91a77..96ec1a1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13198,7 +13198,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
read_profile("/etc/profile");
  state1:
state = 2;
-   read_profile(".profile");
+   const char *hp = lookupvar("HOME");
+   hp = concat_path_file(hp, ".profile");
+   read_profile(hp);
+   free(hp);
}
  state2:
state = 3;
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[PATCH 1/2] ash: move code to allow setting $HOME in /etc/profile

2013-03-02 Thread Stefan Hellermann
move HISTFILE=$HOME/.ash_history below reading /etc/profile,
so that /etc/profile can set $HOME. Home can be unset when
directly invoking ash --login from init without going through
getty.

This removes also a few lines of code.

The lines
+setvar("HISTFILE", hp, 0);
+free(hp);
+hp = lookupvar("HISTFILE");
are added to not leak memory, if this is not important we can
remove the last two lines and save a lookupvar.

Signed-off-by: Stefan Hellermann 

diff --git a/shell/ash.c b/shell/ash.c
index 0b5111a..7c91a77 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13191,19 +13191,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
setstackmark(&smark);
procargs(argv);
 
-#if ENABLE_FEATURE_EDITING_SAVEHISTORY
-   if (iflag) {
-   const char *hp = lookupvar("HISTFILE");
-   if (!hp) {
-   hp = lookupvar("HOME");
-   if (hp) {
-   char *defhp = concat_path_file(hp, 
".ash_history");
-   setvar("HISTFILE", defhp, 0);
-   free(defhp);
-   }
-   }
-   }
-#endif
if (argv[0] && argv[0][0] == '-')
isloginsh = 1;
if (isloginsh) {
@@ -13243,6 +13230,13 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
 #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
if (iflag) {
const char *hp = lookupvar("HISTFILE");
+   if (!hp) {
+   hp = lookupvar("HOME");
+   hp = concat_path_file(hp, ".ash_history");
+   setvar("HISTFILE", hp, 0);
+   free(hp);
+   hp = lookupvar("HISTFILE");
+   }
if (hp)
line_input_state->hist_file = hp;
 # if ENABLE_FEATURE_SH_HISTFILESIZE
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


Re: PATCH: udhcpc -- don't request set of options by default

2008-04-02 Thread Stefan Hellermann
L. Gabriel Somlo schrieb:
>> I am thinking - maybe we should just junk the idea of "default"
>> options to ask for? We can ask user to always provide explicit
>> list of -O OPTs to ask. What do you think?
> 
> I agree. Although others might yell at us if we change default
> behavior :)
> 
>> Please take a look at attached patch - will this work for you?
>>  
> ...
>>  
>> +if (client_config.no_default_options)
>> +return;
>> +
> 
> This returns before -O explicit options have a chance to be added,
> doesn't it ?
> 
>>  packet->options[end + OPT_CODE] = DHCP_PARAM_REQ;
>>  for (i = 0; (c = dhcp_options[i].code) != 0; i++) {
>>  if ((dhcp_options[i].flags & OPTION_REQ)
>> @@ -107,7 +110,9 @@ int send_discover(uint32_t xid, uint32_t
>>  /* Explicitly saying that we want RFC-compliant packets helps
>>   * some buggy DHCP servers to NOT send bigger packets */
>>  add_simple_option(packet.options, DHCP_MAX_SIZE, htons(576));
> 
> Junking default options altogether definitely feels cleaner, no need
> to monkey around with all this '-o' stuff... :) Would anyone be truly
> horrified to see that happen ?

I think I was the one that requested this feature some time ago, and I've no 
problem with
this change, as long as it is mentioned on busybox.net :)

Cheers
Stefan

> 
> BTW, I really did like the [[ %udhcpc_opts%]] idea, I'd like that at
> least to stay... :)
> 
> Thanks,
> --Gabriel
> ___
> busybox mailing list
> busybox@busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: New applet: brctl

2008-01-11 Thread Stefan Hellermann


Vladimir Dronnikov schrieb:
> Hi, list!
> 
> Attached is the patch that adds to BB ability to manage Ethernet bridges.
> It's a stripped down version of brctl utility from GPL
> bridge-utils
> .
> It just helped me to finish tuning of a linux gate which I wanted to be
> controlled entirely by only BB utilities.
> Hope it will be useful!

It will be useful at least for me :) brctl from bridge-utils is very small too, 
but I
think brctl should be in BB too.

> 
> --
> Vladimir Dronnikov
> 
> 
> 
> 
> 
> ___
> busybox mailing list
> busybox@busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: How to request more dhcp-options with udhcpc?

2007-11-30 Thread Stefan Hellermann
William Thompson schrieb:
> On Thu, Nov 29, 2007 at 08:52:07PM -0800, Denys Vlasenko wrote:
>> On Thursday 29 November 2007 16:06, Stefan Hellermann wrote:
>>> Hello!
>>>
>>> I'm trying to get a NFS root-path in a initrd with busybox, but I have to
>>> change the source to select which DHCP-Options it fetches.
>> Please be more specific.
> 
> I believe he's asking for a configurable way to add DHCP options to
> dhcp_options in udhcp/options.c

I don't need to add the DHCP option to udhcp/options.c, it's already there. But 
it's not 
requested from the dhcp-server by default (simply adding " | OPTION_REQ" in 
udhcpc/options.c helps here). I've tried to explain it in my other mail, too.

> 
> I myself would like this ability.  I modified the source (and the
> non-busybox udhcp) to request the SLP options some time ago.
> ___
> busybox mailing list
> busybox@busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: How to request more dhcp-options with udhcpc?

2007-11-30 Thread Stefan Hellermann
Denys Vlasenko schrieb:
> On Thursday 29 November 2007 16:06, Stefan Hellermann wrote:
>> Hello!
>> 
>> I'm trying to get a NFS root-path in a initrd with busybox, but I have to 
>> change the source to select which DHCP-Options it fetches.
> 
> Please be more specific.

I have clients that use nfs-root and would like to get the NFS rootpath via 
DHCP. udhcpc is able to request the rootpath, but doesn't do it by default.
> 
>> Is there a way without changing networking/udhcp/options.c? Is it possible 
>> to create a config-option for custom dhcp-options or a runtime-switch? Or is 
>> there enough demand to fetch it by default?
> 
> I think it is already there - "rootpath" environment variable should be set 
> and passed to script if option 17 (0x11) was in packet from DHCP server.

But usually a DHCP-client asks for a set of options and the DHCP-server only 
responds to the requested options.
udhcpc request the following: subnet, router, dns, hostname, domain, broadcast, 
nisdomain, nissrv, ntpsrv. (networking/udhcpc/options.c)

I need the DHCP-option rootpath too, so I have to patch the source:

--- busybox-1.7.3/networking/udhcp/options.c2007-09-03 13:48:26.0 
+0200
+++ busybox-1.7.3_new/networking/udhcp/options.c2007-11-30 
13:31:46.0 +0100
@@ -25,7 +25,7 @@
 {"bootsize",OPTION_U16, 0x0d},
 {"domain",  OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f},
 {"swapsvr", OPTION_IP,  0x10},
-   {"rootpath",OPTION_STRING,  0x11},
+   {"rootpath",OPTION_STRING | OPTION_REQ,  0x11},
 {"ipttl",   OPTION_U8,  0x17},
 {"mtu", OPTION_U16, 0x1a},
 {"broadcast",   OPTION_IP | OPTION_REQ, 0x1c},


ISCs DHCP could be configured to respond every time with a specific set of 
options, but then I would have to include every single option that some client
sometimes need, also the dhcp-admin wouldn't really like such a change. It's 
much simpler to request the needed DHCP-options with udhcpc.

If there's a runtime-switch you could easily request every DHCP-option you 
need, for example the mtu or the rootpath.
Here's a patch against busybox-1.5.0 which adds this runtime-switch:

--- busybox-1.5.0/networking/udhcp/dhcpc.c  2007-03-22 21:21:23.0 
+0100
+++ busybox-1.5.0_new/networking/udhcp/dhcpc.c  2007-06-02 21:15:34.0 
+0200
@@ -126,7 +126,7 @@ int udhcpc_main(int argc, char *argv[]);
  int udhcpc_main(int argc, char *argv[])
  {
 uint8_t *temp, *message;
-   char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_t;
+   char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_t, *str_O;
 unsigned long t1 = 0, t2 = 0, xid = 0;
 unsigned long start = 0, lease = 0;
 long now;
@@ -160,6 +160,7 @@ int udhcpc_main(int argc, char *argv[])
 OPT_T = 1 << 15,
 OPT_t = 1 << 16,
 OPT_v = 1 << 17,
+   OPT_O = 1 << 18,
 };
  #if ENABLE_GETOPT_LONG
 static const struct option arg_options[] = {
@@ -181,6 +182,7 @@ int udhcpc_main(int argc, char *argv[])
 { "timeout",required_argument,  0, 'T' },
 { "version",no_argument,0, 'v' },
 { "retries",required_argument,  0, 't' },
+   { "request-option", required_argument,  0, 'O' },
 { 0, 0, 0, 0 }
 };
  #endif
@@ -196,10 +198,10 @@ int udhcpc_main(int argc, char *argv[])
  #if ENABLE_GETOPT_LONG
 applet_long_options = arg_options;
  #endif
-   opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v",
+   opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vO:",
 &str_c, &str_V, &str_h, &str_h, &str_F,
 &client_config.interface, &client_config.pidfile, &str_r,
-   &client_config.script, &str_T, &str_t
+   &client_config.script, &str_T, &str_t, &str_O
 );

 if (opt & OPT_c)
@@ -245,6 +247,11 @@ int udhcpc_main(int argc, char *argv[])
 printf("version %s\n\n", BB_VER);
 return 0;
 }
+   if (opt & OPT_O)
+   if (require_option(str_O)) {
+   printf("Option: %s unknown/not-supported\n", str_O);
+   return 1;
+   }

 /* Start the log, sanitize fd's, and 

How to request more dhcp-options with udhcpc?

2007-11-29 Thread Stefan Hellermann
Hello!

I'm trying to get a NFS root-path in a initrd with busybox, but I have to change
the source to select which DHCP-Options it fetches. Is there a way without
changing networking/udhcp/options.c? Is it possible to create a config-option
for custom dhcp-options or a runtime-switch? Or is there enough demand to fetch
it by default?
I have a patch that adds a runtime-switch, but it is against an rather old
version of busybox, I could rebase it if there is demand for this.

Cheers,
Stefan Hellermann

___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox