#endif
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
- { 0,NULL,0 }
+ { 0,NULL,0,0 }
};
#endif
"/dev/tty2\n"
#define udhcpc_trivial_usage \
- "[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
+ "[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
#define udhcpc_full_usage \
- "\t-c,\t--clientid=CLIENTID\tClient identifier\n" \
+ "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
+ "\t-C,\t--clientid-none\tSuppress default client identifier\n" \
"\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
"\t-h,\t \tAlias for -H\n" \
"\t-f,\t--foreground\tDo not fork after getting lease\n" \
if (dest_exists) {
if (flags & FILEUTILS_INTERACTIVE) {
- bb_error_msg("overwrite `%s'? ", dest);
+ fprintf(stderr, "%s: overwrite `%s'? ", bb_applet_name, dest);
if (!bb_ask_confirmation()) {
close (src_fd);
return 0;
if (s1) {
if (s2) {
- fprintf(stream, "%s%s\n", s1, s2);
+ fprintf(stream, "%s%s\r\n", s1, s2);
} else {
- fprintf(stream, "%s\n", s1);
+ fprintf(stream, "%s\r\n", s1);
}
}
do {
post_readed_idx += count;
if(post_readed_size == 0)
post_readed_idx = 0;
+ } else {
+ post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */
}
} else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) {
count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen;
if(count > 0) {
post_readed_size += count;
bodyLen -= count;
- } else {
+ } else {
bodyLen = 0; /* closed */
}
}
byte charmode;
byte telflags;
byte gotsig;
+ byte do_termios;
/* buffer to handle telnet negotiations */
char iacbuf[IACBUFSIZE];
short iaclen; /* could even use byte */
static void rawmode(void)
{
- tcsetattr(0, TCSADRAIN, &G.termios_raw);
+ if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw);
}
static void cookmode(void)
{
- tcsetattr(0, TCSADRAIN, &G.termios_def);
+ if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
}
extern int telnet_main(int argc, char** argv)
memset(&G, 0, sizeof G);
- if (tcgetattr(0, &G.termios_def) < 0)
- exit(1);
+ if (tcgetattr(0, &G.termios_def) >= 0) {
+ G.do_termios = 1;
- G.termios_raw = G.termios_def;
- cfmakeraw(&G.termios_raw);
+ G.termios_raw = G.termios_def;
+ cfmakeraw(&G.termios_raw);
+ }
if (argc < 2)
bb_show_usage();
{
printf(
"Usage: udhcpc [OPTIONS]\n\n"
-" -c, --clientid=CLIENTID Client identifier\n"
+" -c, --clientid=CLIENTID Set client identifier\n"
+" -C, --clientid-none Suppress default client identifier\n"
" -H, --hostname=HOSTNAME Client hostname\n"
" -h Alias for -H\n"
" -f, --foreground Do not fork after getting lease\n"
long now;
int max_fd;
int sig;
+ int no_clientid = 0;
static const struct option arg_options[] = {
{"clientid", required_argument, 0, 'c'},
+ {"clientid-none", no_argument, 0, 'C'},
{"foreground", no_argument, 0, 'f'},
{"background", no_argument, 0, 'b'},
{"hostname", required_argument, 0, 'H'},
/* get options */
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
+ c = getopt_long(argc, argv, "c:CfbH:h:i:np:qr:s:v", arg_options, &option_index);
if (c == -1) break;
switch (c) {
case 'c':
+ if (no_clientid) show_usage();
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
if (client_config.clientid) free(client_config.clientid);
client_config.clientid = xmalloc(len + 2);
client_config.clientid[OPT_DATA] = '\0';
strncpy(client_config.clientid + OPT_DATA, optarg, len);
break;
+ case 'C':
+ if (client_config.clientid) show_usage();
+ no_clientid = 1;
+ break;
case 'f':
client_config.foreground = 1;
break;
NULL, client_config.arp) < 0)
return 1;
- if (!client_config.clientid) {
+ /* if not set, and not suppressed, setup the default client ID */
+ if (!client_config.clientid && !no_clientid) {
client_config.clientid = xmalloc(6 + 3);
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
client_config.clientid[OPT_LEN] = 7;
continue;
}
/* Ignore packets that aren't for us */
- if (memcmp(client_config.arp,packet.chaddr,6))
+ if (memcmp(packet.chaddr, client_config.arp, 6)) {
+ DEBUG(LOG_INFO, "packet does not have our chaddr -- ignoring");
continue;
+ }
if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");
#define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
+#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
static const struct builtincmd builtincmd[] = {
{ BUILTIN_SPEC_REG ".", dotcmd },
}
#endif
-
+static inline int
+isassignment(const char *p)
+{
+ const char *q = endofname(p);
+ if (p == q)
+ return 0;
+ return *q == '=';
+}
/*
* Execute a simple command.
int cmd_is_exec;
int status;
char **nargv;
+ struct builtincmd *bcmd;
+ int pseudovarflag = 0;
/* First expand the arguments. */
TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
*arglist.lastp = NULL;
argc = 0;
+ if (cmd->ncmd.args)
+ {
+ bcmd = find_builtin(cmd->ncmd.args->narg.text);
+ pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
+ }
+
for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
struct strlist **spp;
spp = arglist.lastp;
- expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+ if (pseudovarflag && isassignment(argp->narg.text))
+ expandarg(argp, &arglist, EXP_VARTILDE);
+ else
+ expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+
for (sp = *spp; sp; sp = sp->next)
argc++;
}
-static inline int
-isassignment(const char *p)
-{
- const char *q = endofname(p);
- if (p == q)
- return 0;
- return *q == '=';
-}
-
/*
* Read and parse a command. Returns NEOF on end of file. (NULL is a
INTOFF;
p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
*p++ = '\0';
- if (vallen) {
+ if (val) {
p[-1] = '=';
p = mempcpy(p, val, vallen);
}
#define QUOT (UCHAR_MAX+1)
#define collapse_pos(is, in) { \
- memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
- memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
+ memmove(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
+ memmove(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
static int find_match(char *matchBuf, int *len_with_quotes)
{
}
var_name[var_index++] = *src++;
- while (isalnum(*src))
+ while (isalnum(*src) || *src=='_')
var_name[var_index++] = *src++;
var_name[var_index] = 0;
/* if we have a valid socket, send the message */
if (-1 != remotefd) {
now = 1;
- snprintf(line, sizeof(line), "<%d> %s", pri, msg);
+ snprintf(line, sizeof(line), "<%d>%s", pri, msg);
retry:
/* send message to remote logger */