*** lib/snprintf.c Tue Apr 25 20:06:52 2000 --- /new/lib/snprintf.c Thu Aug 17 14:04:03 2000 *************** *** 49,54 **** --- 49,59 ---- * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * + * Olaf Barthel 15-Oct-99 + * Implemented the missing 'f' and 'g' floating point output + * formats; also fixed handling of floating point numbers + * like "0.01" which would always come out as "0.1". + * **************************************************************/ #include "config.h" *************** *** 59,64 **** --- 64,73 ---- #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) + #ifdef AMIGA + #include + #endif /* AMIGA */ + /* Define this as a fall through, HAVE_STDARG_H is probably already set */ #define HAVE_VARARGS_H *************** *** 107,113 **** static void fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* --- 116,122 ---- static void fmtint (char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags, char ch); static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c ); /* *************** *** 326,332 **** else fvalue = va_arg (args, double); /* um, floating point? */ ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; --- 335,341 ---- else fvalue = va_arg (args, double); /* um, floating point? */ ! fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'E': flags |= DP_F_UP; *************** *** 335,340 **** --- 344,351 ---- fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'G': flags |= DP_F_UP; *************** *** 343,348 **** --- 354,361 ---- fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); + /* um, floating point? */ + fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, ch); break; case 'c': dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); *************** *** 577,584 **** } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; LDOUBLE ufvalue; #ifndef HAVE_FCVT --- 590,604 ---- } static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, ! LDOUBLE fvalue, int min, int max, int flags, char ch) { + enum /* olsen: output formats to be used below. */ + { + FORMAT_f, + FORMAT_g, + FORMAT_e + }; + int signvalue = 0; LDOUBLE ufvalue; #ifndef HAVE_FCVT *************** *** 593,599 **** --- 613,621 ---- # ifdef HAVE_FCVTL extern char *fcvtl(long double value, int ndigit, int *decpt, int *sign); # else + #ifndef AMIGA extern char *fcvt(double value, int ndigit, int *decpt, int *sign); + #endif /* AMIGA */ # endif #endif int iplace = 0; *************** *** 603,609 **** int caps = 0; long intpart; long fracpart; ! /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 --- 625,635 ---- int caps = 0; long intpart; long fracpart; ! int exponent; ! int exponentLen; ! int outputFmt; ! int decimalPointLen; ! /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 *************** *** 622,627 **** --- 648,696 ---- if (flags & DP_F_SPACE) signvalue = ' '; + /* olsen: determine the output format. */ + if(ch == 'g' || ch == 'G') + outputFmt = FORMAT_g; + else if (ch == 'e' || ch == 'E') + outputFmt = FORMAT_e; + else + outputFmt = FORMAT_f; + + /* olsen: calculate the exponent */ + exponent = 0; + if(ufvalue > 0.0 && outputFmt != FORMAT_f) + { + LDOUBLE value = ufvalue; + + /* Make sure that the integer part + * comes out as a single digit. + */ + if(value < 1.0) + { + do + { + value *= 10.0; + exponent--; + } + while(value < 1.0); + } + else if(value > 10.0) + { + do + { + value /= 10.0; + exponent++; + } + while(value > 10.0); + } + + /* Don't change the base unless we are to output + * the number in scientific format. + */ + if((outputFmt == FORMAT_e) || (outputFmt == FORMAT_g && exponent < -4)) + ufvalue = value; + } + #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif *************** *** 659,674 **** intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) iplace--; ! iconvert[iplace] = 0; /* Convert fractional part */ do { fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; fracpart = (fracpart / 10); ! } while(fracpart && (fplace < 20)); if (fplace == 20) fplace--; ! fconvert[fplace] = 0; #else /* use fcvt() */ if (max > 310) max = 310; --- 728,752 ---- intpart = (intpart / 10); } while(intpart && (iplace < 20)); if (iplace == 20) iplace--; ! iconvert[iplace] = '\0'; /* Convert fractional part */ do { fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10]; fracpart = (fracpart / 10); ! } while(fracpart != 0 && (fplace < 20)); ! ! /* olsen: we need to make up for numbers like 0.01 ! * which would come out as "0.1" unless ! * we add a few padding zeroes. ! */ ! while(fplace < 20 && fplace < max) ! fconvert[fplace++] = '0'; ! if (fplace == 20) fplace--; ! fconvert[fplace] = '\0'; ! #else /* use fcvt() */ if (max > 310) max = 310; *************** *** 724,731 **** } #endif /* fcvt */ /* -1 for decimal point, another -1 if we are printing a sign */ ! padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; --- 802,871 ---- } #endif /* fcvt */ + /* olsen: eliminate trailing zeroes. */ + decimalPointLen = (max > 0) ? 1 : 0; + exponentLen = 0; + if(outputFmt == FORMAT_g) + { + int i,numTrailingZeroes; + + /* Count the number of trailing zeroes. */ + numTrailingZeroes = 0; + for(i = 0 ; i < fplace ; i++) + { + if(fconvert[i] == '0') + numTrailingZeroes++; + else + break; + } + + /* If there are any, remove them. */ + if(numTrailingZeroes > 0) + { + /* Remove the zeroes, if necessary. + * Otherwise, just forget that we + * had any digits in the fractional + * part. + */ + if(numTrailingZeroes != fplace) + { + for(i = 0 ; i < fplace-numTrailingZeroes ; i++) + fconvert[i] = fconvert[numTrailingZeroes+i]; + } + + fplace -= numTrailingZeroes; + fconvert[fplace] = '\0'; + + /* Don't print the decimal point if + * there is nothing to follow it. + */ + if(fplace == 0) + decimalPointLen = 0; + } + + /* Switch to scientific output format + * if the exponent is too small. + */ + if(exponent < -4) + { + /* Two digits for the "e+" and + * at least two digits for the number + * to follow the sign. + */ + exponentLen = (int)log10((LDOUBLE)exponent) + 2; + if(exponentLen < 4) + exponentLen = 4; + } + } + else if(outputFmt == FORMAT_e) + { + exponentLen = (int)log10((LDOUBLE)exponent) + 2; + if(exponentLen < 4) + exponentLen = 4; + } + /* -1 for decimal point, another -1 if we are printing a sign */ ! padlen = min - iplace - max - decimalPointLen - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; *************** *** 734,739 **** --- 874,883 ---- if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ + /* olsen: eliminate trailing zeroes. */ + if(outputFmt == FORMAT_g) + zpadlen = 0; + if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) *************** *** 768,774 **** * Decimal point. This should probably use locale to find the correct * char to print out. */ ! if (max > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) --- 912,918 ---- * Decimal point. This should probably use locale to find the correct * char to print out. */ ! if (max > 0 && decimalPointLen > 0) { dopr_outch (buffer, currlen, maxlen, '.'); while (fplace > 0) *************** *** 781,786 **** --- 925,959 ---- --zpadlen; } + /* olsen: output the exponent */ + if(exponentLen > 0) + { + char expChars[10]; + int numExpChars; + int i; + + dopr_outch (buffer, currlen, maxlen, caps?'E':'e'); + if(exponent < 0) + { + dopr_outch (buffer, currlen, maxlen, '-'); + exponent = (-exponent); + } + else + { + dopr_outch (buffer, currlen, maxlen, '+'); + } + + numExpChars = 0; + for(i = 0 ; i < exponentLen-2 && i < sizeof(expChars)-1 ; i++) + { + expChars[numExpChars++] = '0' + (exponent % 10); + exponent /= 10; + } + + while(numExpChars > 0) + dopr_outch (buffer, currlen, maxlen, expChars[--numExpChars]); + } + while (padlen < 0) { dopr_outch (buffer, currlen, maxlen, ' '); *************** *** 856,861 **** --- 1029,1063 ---- "%3.2f", "%.0f", "%.1f", + + "%-1.5g", + "%1.5g", + "%123.9g", + "%10.5g", + "% 10.5g", + "%+22.9g", + "%+4.9g", + "%01.3g", + "%4g", + "%3.1g", + "%3.2g", + "%.0g", + "%.1g", + + "%-1.5e", + "%1.5e", + "%123.9e", + "%10.5e", + "% 10.5e", + "%+22.9e", + "%+4.9e", + "%01.3e", + "%4e", + "%3.1e", + "%3.2e", + "%.0e", + "%.1e", + NULL }; double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, *************** *** 908,912 **** } printf ("%d tests failed out of %d.\n", fail, num); } ! #endif /* SNPRINTF_TEST */ --- 1110,1114 ---- } printf ("%d tests failed out of %d.\n", fail, num); } ! #endif /* TEST_SNPRINTF */ *** lib/smbrun.c Tue Jul 20 22:25:09 1999 --- /new/lib/smbrun.c Mon May 22 18:36:17 2000 *************** *** 91,96 **** --- 91,99 ---- set_process_capability(KERNEL_OPLOCK_CAPABILITY, False); set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY, False); + #ifdef AMIGA + return(amiga_smbrun(cmd,outfile,shared)); + #else #ifndef HAVE_EXECL int ret; pstring syscmd; *************** *** 195,198 **** --- 198,202 ---- exit(82); #endif return 1; + #endif /* AMIGA */ } *** lib/system.c Tue Apr 25 20:06:52 2000 --- /new/lib/system.c Mon May 22 19:02:10 2000 *************** *** 795,955 **** FILE *sys_popen(const char *command, const char *mode, BOOL paranoid) { ! int parent_end, child_end; ! int pipe_fds[2]; ! popen_list *entry = NULL; ! char **argl = NULL; ! ! if (pipe(pipe_fds) < 0) ! return NULL; ! ! if (mode[0] == 'r' && mode[1] == '\0') { ! parent_end = pipe_fds[0]; ! child_end = pipe_fds[1]; ! } else if (mode[0] == 'w' && mode[1] == '\0') { ! parent_end = pipe_fds[1]; ! child_end = pipe_fds[0]; ! } else { ! errno = EINVAL; ! goto err_exit; ! } ! ! if (!*command) { ! errno = EINVAL; ! goto err_exit; } ! if((entry = (popen_list *)malloc(sizeof(popen_list))) == NULL) ! goto err_exit; ! ! /* ! * Extract the command and args into a NULL terminated array. ! */ ! if(!(argl = extract_args(command))) ! goto err_exit; - if(paranoid) { /* ! * Do some basic paranioa checks. Do a stat on the parent ! * directory and ensure it's not world writable. Do a stat ! * on the file itself and ensure it's owned by root and not ! * world writable. Note this does *not* prevent symlink races, ! * but is a generic "don't let the admin screw themselves" ! * check. */ ! SMB_STRUCT_STAT st; ! pstring dir_name; ! char *ptr = strrchr(argl[0], '/'); ! ! if(sys_stat(argl[0], &st) != 0) goto err_exit; ! if((st.st_uid != (uid_t)0) || (st.st_mode & S_IWOTH)) { ! errno = EACCES; ! goto err_exit; ! } ! ! if(!ptr) { /* ! * No '/' in name - use current directory. */ - pstrcpy(dir_name, "."); - } else { ! /* ! * Copy into a pstring and do the checks ! * again (in case we were length tuncated). ! */ ! pstrcpy(dir_name, argl[0]); ! ptr = strrchr(dir_name, '/'); ! if(!ptr) { ! errno = EINVAL; goto err_exit; } ! if(strcmp(dir_name, "/") != 0) ! *ptr = '\0'; ! if(!dir_name[0]) pstrcpy(dir_name, "."); } ! if(sys_stat(argl[0], &st) != 0) ! goto err_exit; - if(!S_ISDIR(st.st_mode) || (st.st_mode & S_IWOTH)) { - errno = EACCES; goto err_exit; } - } ! entry->child_pid = fork(); ! if (entry->child_pid == -1) { ! ! /* ! * Error ! ! */ ! goto err_exit; ! } ! if (entry->child_pid == 0) { ! /* ! * Child ! ! */ ! int child_std_end = (mode[0] == 'r') ? STDOUT_FILENO : STDIN_FILENO; ! popen_list *p; ! close(parent_end); ! if (child_end != child_std_end) { ! dup2 (child_end, child_std_end); ! close (child_end); } /* ! * POSIX.2: "popen() shall ensure that any streams from previous ! * popen() calls that remain open in the parent process are closed ! * in the new child process." */ ! for (p = popen_chain; p; p = p->next) ! close(fileno(p->fp)); ! ! execv(argl[0], argl); ! _exit (127); ! } ! ! /* ! * Parent. ! */ ! ! close (child_end); ! free((char *)argl); ! ! /* ! * Create the FILE * representing this fd. ! */ ! entry->fp = fdopen(parent_end, mode); ! ! /* Link into popen_chain. */ ! entry->next = popen_chain; ! popen_chain = entry; ! ! return entry->fp; ! err_exit: ! if(entry) ! free((char *)entry); ! if(argl) ! free((char *)argl); ! close(pipe_fds[0]); ! close(pipe_fds[1]); ! return NULL; } /************************************************************************** --- 795,963 ---- FILE *sys_popen(const char *command, const char *mode, BOOL paranoid) { ! #ifdef AMIGA ! { ! return( amiga_popen(command,mode) ); } + #else + { + int parent_end, child_end; + int pipe_fds[2]; + popen_list *entry = NULL; + char **argl = NULL; + + if (pipe(pipe_fds) < 0) + return NULL; + + if (mode[0] == 'r' && mode[1] == '\0') { + parent_end = pipe_fds[0]; + child_end = pipe_fds[1]; + } else if (mode[0] == 'w' && mode[1] == '\0') { + parent_end = pipe_fds[1]; + child_end = pipe_fds[0]; + } else { + errno = EINVAL; + goto err_exit; + } ! if (!*command) { ! errno = EINVAL; ! goto err_exit; ! } ! if((entry = (popen_list *)malloc(sizeof(popen_list))) == NULL) ! goto err_exit; /* ! * Extract the command and args into a NULL terminated array. */ ! if(!(argl = extract_args(command))) goto err_exit; ! if(paranoid) { /* ! * Do some basic paranioa checks. Do a stat on the parent ! * directory and ensure it's not world writable. Do a stat ! * on the file itself and ensure it's owned by root and not ! * world writable. Note this does *not* prevent symlink races, ! * but is a generic "don't let the admin screw themselves" ! * check. */ ! SMB_STRUCT_STAT st; ! pstring dir_name; ! char *ptr = strrchr(argl[0], '/'); ! ! if(sys_stat(argl[0], &st) != 0) ! goto err_exit; ! if((st.st_uid != (uid_t)0) || (st.st_mode & S_IWOTH)) { ! errno = EACCES; goto err_exit; } ! ! if(!ptr) { ! /* ! * No '/' in name - use current directory. ! */ pstrcpy(dir_name, "."); + } else { + + /* + * Copy into a pstring and do the checks + * again (in case we were length tuncated). + */ + + pstrcpy(dir_name, argl[0]); + ptr = strrchr(dir_name, '/'); + if(!ptr) { + errno = EINVAL; + goto err_exit; + } + if(strcmp(dir_name, "/") != 0) + *ptr = '\0'; + if(!dir_name[0]) + pstrcpy(dir_name, "."); + } + + if(sys_stat(argl[0], &st) != 0) + goto err_exit; + + if(!S_ISDIR(st.st_mode) || (st.st_mode & S_IWOTH)) { + errno = EACCES; + goto err_exit; + } } ! entry->child_pid = fork(); ! ! if (entry->child_pid == -1) { ! ! /* ! * Error ! ! */ goto err_exit; } ! if (entry->child_pid == 0) { ! /* ! * Child ! ! */ ! int child_std_end = (mode[0] == 'r') ? STDOUT_FILENO : STDIN_FILENO; ! popen_list *p; ! close(parent_end); ! if (child_end != child_std_end) { ! dup2 (child_end, child_std_end); ! close (child_end); ! } ! /* ! * POSIX.2: "popen() shall ensure that any streams from previous ! * popen() calls that remain open in the parent process are closed ! * in the new child process." ! */ ! for (p = popen_chain; p; p = p->next) ! close(fileno(p->fp)); ! execv(argl[0], argl); ! _exit (127); } /* ! * Parent. */ ! close (child_end); ! free((char *)argl); ! /* ! * Create the FILE * representing this fd. ! */ ! entry->fp = fdopen(parent_end, mode); ! /* Link into popen_chain. */ ! entry->next = popen_chain; ! popen_chain = entry; ! ! return entry->fp; ! ! err_exit: ! ! if(entry) ! free((char *)entry); ! if(argl) ! free((char *)argl); ! close(pipe_fds[0]); ! close(pipe_fds[1]); ! return NULL; ! } ! #endif /* AMIGA */ } /************************************************************************** *************** *** 958,995 **** int sys_pclose( FILE *fp) { ! int wstatus; ! popen_list **ptr = &popen_chain; ! popen_list *entry = NULL; ! pid_t wait_pid; ! int status = -1; ! ! /* Unlink from popen_chain. */ ! for ( ; *ptr != NULL; ptr = &(*ptr)->next) { ! if ((*ptr)->fp == fp) { ! entry = *ptr; ! *ptr = (*ptr)->next; ! status = 0; ! break; ! } } ! if (status < 0 || close(fileno(entry->fp)) < 0) ! return -1; ! /* ! * As Samba is catching and eating child process ! * exits we don't really care about the child exit ! * code, a -1 with errno = ECHILD will do fine for us. ! */ ! ! do { ! wait_pid = sys_waitpid (entry->child_pid, &wstatus, 0); ! } while (wait_pid == -1 && errno == EINTR); ! ! free((char *)entry); ! ! if (wait_pid == -1) ! return -1; ! return wstatus; } --- 966,1012 ---- int sys_pclose( FILE *fp) { ! #ifdef AMIGA ! { ! return( amiga_pclose(fp) ); } + #else + { + int wstatus; + popen_list **ptr = &popen_chain; + popen_list *entry = NULL; + pid_t wait_pid; + int status = -1; + + /* Unlink from popen_chain. */ + for ( ; *ptr != NULL; ptr = &(*ptr)->next) { + if ((*ptr)->fp == fp) { + entry = *ptr; + *ptr = (*ptr)->next; + status = 0; + break; + } + } ! if (status < 0 || close(fileno(entry->fp)) < 0) ! return -1; ! /* ! * As Samba is catching and eating child process ! * exits we don't really care about the child exit ! * code, a -1 with errno = ECHILD will do fine for us. ! */ ! ! do { ! wait_pid = sys_waitpid (entry->child_pid, &wstatus, 0); ! } while (wait_pid == -1 && errno == EINTR); ! ! free((char *)entry); ! ! if (wait_pid == -1) ! return -1; ! ! return wstatus; ! } ! #endif /* AMIGA */ } *** lib/util.c Tue Apr 25 20:06:53 2000 --- /new/lib/util.c Wed Aug 29 12:49:43 2001 *************** *** 112,122 **** --- 112,133 ---- ****************************************************************************/ char *tmpdir(void) { + #ifndef AMIGA + char *p; if ((p = getenv("TMPDIR"))) { return p; } return "/tmp"; + + #else + + /* olsen: we always return "/T" which will end up getting + * translated into "T:" by the emulation layer. + */ + return "/T"; + + #endif /* AMIGA */ } /**************************************************************************** *************** *** 1517,1522 **** --- 1528,1540 ---- ****************************************************************************/ void become_daemon(void) { + #ifdef AMIGA + { + DEBUG(2,("Warning: become_daemon() not done.\n")); + return; + } + #endif /* AMIGA */ + if (fork()) { _exit(0); } *** lib/interfaces.c Tue Apr 25 20:06:50 2000 --- /new/lib/interfaces.c Mon May 22 18:01:33 2000 *************** *** 335,340 **** --- 335,349 ---- return total; } + #elif defined(AMIGA) + + static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) + { + extern int amiga_get_interfaces(struct iface_struct * ifaces,int max_interfaces); + + return(amiga_get_interfaces(ifaces,max_interfaces)); + } + #else /* a dummy version */ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) { *** lib/interface.c Wed Oct 13 02:26:48 1999 --- /new/lib/interface.c Mon May 22 18:01:33 2000 *************** *** 234,243 **** n = get_interfaces(ifaces, MAX_INTERFACES); ! if (n != total_probed || ! memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) { ! return True; } return False; } --- 234,255 ---- n = get_interfaces(ifaces, MAX_INTERFACES); ! /* olsen: probed_ifaces can be NULL! */ ! #ifdef AMIGA ! { ! if (n != total_probed || ! (probed_ifaces != NULL && memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n))) { ! return True; ! } } + #else + { + if (n != total_probed || + memcmp(ifaces, probed_ifaces, sizeof(ifaces[0])*n)) { + return True; + } + } + #endif return False; } *** lib/genrand.c Tue Jul 20 22:25:08 1999 --- /new/lib/genrand.c Wed Aug 29 12:36:37 2001 *************** *** 125,130 **** --- 125,132 ---- memset(md4_inbuf, '\0', sizeof(md4_inbuf)); + #ifndef AMIGA + fd = sys_open( "/dev/urandom", O_RDONLY,0); if(fd >= 0) { /* *************** *** 147,152 **** --- 149,163 ---- /* possibly add in some secret file contents */ do_filehash("/etc/shadow", &md4_inbuf[0]); do_filehash(lp_smb_passwd_file(), &md4_inbuf[16]); + + #else + + /* olsen: AmigaOS has neither of these facilities. We just + * try the SMB password file. + */ + do_filehash(lp_smb_passwd_file(), &md4_inbuf[16]); + + #endif /* AMIGA */ /* add in the root encrypted password. On any system where security is taken seriously this will be secret */ *** web/cgi.c Tue Apr 25 20:07:17 2000 --- /new/web/cgi.c Mon May 22 18:49:31 2000 *************** *** 198,204 **** } fclose(stdin); ! (void)open("/dev/null", O_RDWR); if ((s=query_string) || (s=getenv("QUERY_STRING"))) { for (tok=strtok(s,"&;");tok;tok=strtok(NULL,"&;")) { --- 198,209 ---- } fclose(stdin); ! ! #ifndef AMIGA ! { ! (void)open("/dev/null", O_RDWR); ! } ! #endif /* AMIGA */ if ((s=query_string) || (s=getenv("QUERY_STRING"))) { for (tok=strtok(s,"&;");tok;tok=strtok(NULL,"&;")) { *** web/swat.c Tue Apr 25 20:07:17 2000 --- /new/web/swat.c Tue Nov 14 14:18:32 2000 *************** *** 338,343 **** --- 338,348 ---- static int save_reload(int snum) { FILE *f; + pstring servicesfbak; + + pstrcpy(servicesfbak, servicesf); + pstrcpy(servicesfbak+strlen(servicesf),".bak\0"); + rename(servicesf, servicesfbak); f = sys_fopen(servicesf,"w"); if (!f) { *************** *** 980,987 **** if (!dbf) dbf = stderr; /* we don't want stderr screwing us up */ ! close(2); ! open("/dev/null", O_WRONLY); while ((opt = getopt(argc, argv,"s:a")) != EOF) { switch (opt) { --- 985,996 ---- if (!dbf) dbf = stderr; /* we don't want stderr screwing us up */ ! #ifndef AMIGA ! { ! close(2); ! open("/dev/null", O_WRONLY); ! } ! #endif /* AMIGA */ while ((opt = getopt(argc, argv,"s:a")) != EOF) { switch (opt) { *** smbd/reply.c Tue Apr 25 22:06:22 2000 --- /new/smbd/reply.c Mon May 22 18:01:38 2000 *************** *** 971,977 **** char *p; set_message(outbuf,3,3,True); p = smb_buf(outbuf); ! pstrcpy(p,"Unix"); p = skip_string(p,1); pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1); pstrcpy(p,global_myworkgroup); p = skip_string(p,1); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); --- 971,985 ---- char *p; set_message(outbuf,3,3,True); p = smb_buf(outbuf); ! #ifdef AMIGA ! { ! pstrcpy(p,"AmigaOS"); p = skip_string(p,1); ! } ! #else ! { ! pstrcpy(p,"Unix"); p = skip_string(p,1); ! } ! #endif /* AMIGA */ pstrcpy(p,"Samba "); pstrcat(p,VERSION); p = skip_string(p,1); pstrcpy(p,global_myworkgroup); p = skip_string(p,1); set_message(outbuf,3,PTR_DIFF(p,smb_buf(outbuf)),False); *** smbd/negprot.c Tue Apr 25 20:07:10 2000 --- /new/smbd/negprot.c Thu Jun 07 11:32:45 2001 *************** *** 160,165 **** --- 160,166 ---- /* dual names + lock_and_read + nt SMBs + remote API calls */ int capabilities = CAP_NT_FIND|CAP_LOCK_AND_READ| (lp_nt_smb_support() ? CAP_NT_SMBS | CAP_RPC_REMOTE_APIS : 0) | + CAP_LARGE_READX | CAP_LARGE_WRITEX | (SMB_OFF_T_BITS == 64 ? CAP_LARGE_FILES : 0); *** smbd/password.c Tue Apr 25 20:07:11 2000 --- /new/smbd/password.c Mon Nov 13 20:04:45 2000 *************** *** 352,362 **** unsigned char p21[21]; unsigned char p24[24]; ! if (part_passwd == NULL) ! DEBUG(10,("No password set - allowing access\n")); ! /* No password set - always true ! */ ! if (part_passwd == NULL) ! return 1; memset(p21,'\0',21); memcpy(p21,part_passwd,16); --- 352,362 ---- unsigned char p21[21]; unsigned char p24[24]; ! if (part_passwd == NULL) { ! DEBUG(10,("No password set - disallowing access\n")); ! /* No password set - always false */ ! return False; ! } memset(p21,'\0',21); memcpy(p21,part_passwd,16); *************** *** 399,410 **** DEBUG(4,("Checking SMB password for user %s\n", smb_pass->smb_name)); - if(smb_pass->acct_ctrl & ACB_DISABLED) { - DEBUG(1,("account for user %s was disabled.\n", - smb_pass->smb_name)); - return(False); - } - if (chal == NULL) { DEBUG(5,("use last SMBnegprot challenge\n")); --- 399,404 ---- *************** *** 434,451 **** DEBUG(4,("NT MD4 password check failed\n")); } ! /* Try against the lanman password. smb_pass->smb_passwd == NULL means ! no password, allow access. */ DEBUG(4,("Checking LM MD4 password\n")); - if((smb_pass->smb_passwd == NULL) && - (smb_pass->acct_ctrl & ACB_PWNOTREQ)) { - DEBUG(4,("no password required for user %s\n", - smb_pass->smb_name)); - return True; - } - if((smb_pass->smb_passwd != NULL) && smb_password_check((char *)lm_pass, (uchar *)smb_pass->smb_passwd, challenge)) { --- 428,438 ---- DEBUG(4,("NT MD4 password check failed\n")); } ! /* Try against the lanman password. ! */ DEBUG(4,("Checking LM MD4 password\n")); if((smb_pass->smb_passwd != NULL) && smb_password_check((char *)lm_pass, (uchar *)smb_pass->smb_passwd, challenge)) { *************** *** 514,520 **** return(False); } ! if (lm_pwd[0] == '\0' && IS_BITS_SET_ALL(smb_pass->acct_ctrl, ACB_PWNOTREQ) && lp_null_passwords()) { DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", smb_pass->smb_name)); return(True); --- 501,507 ---- return(False); } ! if ((smb_pass->acct_ctrl & ACB_PWNOTREQ) && lp_null_passwords()) { DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n", smb_pass->smb_name)); return(True); *************** *** 536,541 **** --- 523,539 ---- ****************************************************************************/ BOOL password_ok(char *user, char *password, int pwlen, struct passwd *pwd) { + /* This cuts null passwords off at the pass, getting around the mess in the + password checking fuctions and stops the 'PAM: Authentication failure' + messages. + */ + + if ((pwlen == 0) && !lp_null_passwords()) + { + DEBUG(4,("Null passwords not allowed.\n")); + return False; + } + if (pwlen == 24 || (lp_encrypted_passwords() && (pwlen == 0) && lp_null_passwords())) { /* if 24 bytes long assume it is an encrypted password */ *** passdb/smbpass.c Tue Apr 25 20:07:01 2000 --- /new/passdb/smbpass.c Mon May 22 18:53:19 2000 *************** *** 148,161 **** /* Set a buffer to do more efficient reads */ setvbuf(fp, (char *)NULL, _IOFBF, 1024); /* Make sure it is only rw by the owner */ ! if(fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) { ! DEBUG(0, ("startsmbfilepwent_internal: failed to set 0600 permissions on password file %s. \ Error was %s\n.", pfile, strerror(errno) )); ! pw_file_unlock(fileno(fp), lock_depth); ! fclose(fp); ! return NULL; } /* We have a lock on the file. */ return (void *)fp; --- 148,165 ---- /* Set a buffer to do more efficient reads */ setvbuf(fp, (char *)NULL, _IOFBF, 1024); + #ifndef AMIGA + { /* Make sure it is only rw by the owner */ ! if(fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1) { ! DEBUG(0, ("startsmbfilepwent_internal: failed to set 0600 permissions on password file %s. \ Error was %s\n.", pfile, strerror(errno) )); ! pw_file_unlock(fileno(fp), lock_depth); ! fclose(fp); ! return NULL; ! } } + #endif /* AMIGA */ /* We have a lock on the file. */ return (void *)fp; *** include/smb.h Tue Apr 25 20:06:49 2000 --- /new/include/smb.h Thu Jun 07 11:32:31 2001 *************** *** 1613,1618 **** --- 1613,1619 ---- #define CAP_NT_FIND 0x0200 #define CAP_DFS 0x1000 #define CAP_LARGE_READX 0x4000 + #define CAP_LARGE_WRITEX 0x8000 #define CAP_EXTENDED_SECURITY 0x80000000 /* protocol types. It assumes that higher protocols include lower protocols *** include/includes.h Tue Apr 25 20:06:46 2000 --- /new/include/includes.h Mon May 22 18:01:26 2000 *************** *** 21,26 **** --- 21,36 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #ifdef AMIGA + /* This type definition clashes with one + * used in the Samba code, which is why + * we hide it. + */ + #define BOOL __BOOL + #include + #undef BOOL + #endif /* AMIGA */ + #ifndef NO_CONFIG_H /* for some tests */ #include "config.h" #endif *************** *** 880,885 **** --- 890,906 ---- /* yuck, I'd like a better way of doing this */ #define DIRP_SIZE (256 + 32) + + #ifdef AMIGA + /* Remap a couple of library routines. */ + #include "amiga.h" + + /* These clash with local definitions in "smbd/ipc.c", + * which is why we undefine them. + */ + #undef ACCESS_READ + #undef ACCESS_WRITE + #endif /* AMIGA */ /* * glibc on linux doesn't seem to have MSG_WAITALL *** tests/summary.c Wed Oct 13 02:27:01 1999 --- /new/tests/summary.c Mon May 22 17:21:33 2000 *************** *** 4,10 **** { #if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64)) printf("ERROR: No locking available. Running Samba would be unsafe\n"); ! exit(1); #endif #if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP)) --- 4,10 ---- { #if !(defined(HAVE_FCNTL_LOCK) || defined(HAVE_STRUCT_FLOCK64)) printf("ERROR: No locking available. Running Samba would be unsafe\n"); ! /*exit(1);*/ #endif #if !(defined(HAVE_SYSV_IPC) || defined(HAVE_SHARED_MMAP)) *************** *** 17,33 **** #if !(defined(USE_SETEUID) || defined(USE_SETREUID) || defined(USE_SETRESUID) || defined(USE_SETUIDX)) printf("ERROR: no seteuid method available\n"); ! exit(1); #endif #if !(defined(STAT_STATVFS) || defined(STAT_STATVFS64) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA)) printf("ERROR: No disk free routine!\n"); ! exit(1); #endif #if !((defined(HAVE_RANDOM) || defined(HAVE_RAND)) && (defined(HAVE_SRANDOM) || defined(HAVE_SRAND))) printf("ERROR: No random or srandom routine!\n"); ! exit(1); #endif exit(0); --- 17,33 ---- #if !(defined(USE_SETEUID) || defined(USE_SETREUID) || defined(USE_SETRESUID) || defined(USE_SETUIDX)) printf("ERROR: no seteuid method available\n"); ! /*exit(1);*/ #endif #if !(defined(STAT_STATVFS) || defined(STAT_STATVFS64) || defined(STAT_STATFS3_OSF1) || defined(STAT_STATFS2_BSIZE) || defined(STAT_STATFS4) || defined(STAT_STATFS2_FSIZE) || defined(STAT_STATFS2_FS_DATA)) printf("ERROR: No disk free routine!\n"); ! /*exit(1);*/ #endif #if !((defined(HAVE_RANDOM) || defined(HAVE_RAND)) && (defined(HAVE_SRANDOM) || defined(HAVE_SRAND))) printf("ERROR: No random or srandom routine!\n"); ! /*exit(1);*/ #endif exit(0); *** utils/testparm.c Wed Oct 13 02:27:03 1999 --- /new/utils/testparm.c Thu Aug 17 14:42:14 2000 *************** *** 70,78 **** lp_lockdir()); ret = 1; } else if ((st.st_mode & 0777) != 0755) { ! printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n", ! lp_lockdir()); ! ret = 1; } /* --- 70,88 ---- lp_lockdir()); ret = 1; } else if ((st.st_mode & 0777) != 0755) { ! /* olsen: This is not necessary on the Amiga and always ! * seems to be a source of confusion when users ! * try to determine what's wrong with their ! * configurations. ! */ ! ! #ifndef AMIGA ! { ! printf("WARNING: lock directory %s should have permissions 0755 for browsing to work\n", ! lp_lockdir()); ! ret = 1; ! } ! #endif /* AMIGA */ } /* *** libsmb/clientgen.c Tue Apr 25 20:06:54 2000 --- /new/libsmb/clientgen.c Mon May 22 18:01:36 2000 *************** *** 876,882 **** pstrcpy(p,workgroup); strupper(p); p = skip_string(p,1); ! pstrcpy(p,"Unix");p = skip_string(p,1); pstrcpy(p,"Samba");p = skip_string(p,1); set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); } --- 876,890 ---- pstrcpy(p,workgroup); strupper(p); p = skip_string(p,1); ! #ifdef AMIGA ! { ! pstrcpy(p,"AmigaOS");p = skip_string(p,1); ! } ! #else ! { ! pstrcpy(p,"Unix");p = skip_string(p,1); ! } ! #endif /* AMIGA */ pstrcpy(p,"Samba");p = skip_string(p,1); set_message(cli->outbuf,13,PTR_DIFF(p,smb_buf(cli->outbuf)),False); } *** client/client.c Tue Apr 25 20:06:41 2000 --- /new/client/client.c Thu Feb 01 16:16:34 2001 *************** *** 173,180 **** return; } ! ! printf("Connected. Type your message, ending it with a Control-D\n"); while (!feof(stdin) && total_len < 1600) { int maxlen = MIN(1600 - total_len,127); --- 173,187 ---- return; } ! #ifndef AMIGA ! { ! printf("Connected. Type your message, ending it with a Control-D\n"); ! } ! #else ! { ! printf("Connected. Type your message, ending it with a Control-\\\n"); ! } ! #endif /* AMIGA */ while (!feof(stdin) && total_len < 1600) { int maxlen = MIN(1600 - total_len,127); *************** *** 668,674 **** if(!strcmp(lname,"-")) { handle = fileno(stdout); } else { ! handle = sys_open(lname,O_WRONLY|O_CREAT|O_TRUNC,0644); newhandle = True; } if (handle < 0) { --- 675,681 ---- if(!strcmp(lname,"-")) { handle = fileno(stdout); } else { ! handle = sys_open(lname,O_WRONLY|O_CREAT,0644); newhandle = True; } if (handle < 0) { *************** *** 693,698 **** --- 700,707 ---- cli_close(cli, fnum); return; } + + nread = lseek(handle, 0, SEEK_END); while (1) { int n = cli_read(cli, fnum, data, nread, read_size);