crypt_server.c (29735) | crypt_server.c (39319) |
---|---|
1/* 2 * Copyright (c) 1996 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39#include <stdlib.h> 40#include <string.h> 41#include <rpc/des_crypt.h> 42#include <rpc/des.h> 43#include "crypt.h" 44 45#ifndef lint 46static const char rcsid[] = | 1/* 2 * Copyright (c) 1996 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 30 unchanged lines hidden (view full) --- 39#include <stdlib.h> 40#include <string.h> 41#include <rpc/des_crypt.h> 42#include <rpc/des.h> 43#include "crypt.h" 44 45#ifndef lint 46static const char rcsid[] = |
47 "$Id$"; | 47 "$Id: crypt_server.c,v 1.3 1997/09/23 06:36:26 charnier Exp $"; |
48#endif /* not lint */ 49 50/* 51 * The U.S. government stupidly believes that a) it can keep strong 52 * crypto code a secret and b) that doing so somehow protects national 53 * interests. It's wrong on both counts, but until it listens to reason 54 * we have to make certain compromises so it doesn't have an excuse to 55 * throw us in federal prison. --- 110 unchanged lines hidden (view full) --- 166 167static void *dlhandle; 168 169#ifndef _PATH_USRLIB 170#define _PATH_USRLIB "/usr/lib" 171#endif 172 173#ifndef LIBDES | 48#endif /* not lint */ 49 50/* 51 * The U.S. government stupidly believes that a) it can keep strong 52 * crypto code a secret and b) that doing so somehow protects national 53 * interests. It's wrong on both counts, but until it listens to reason 54 * we have to make certain compromises so it doesn't have an excuse to 55 * throw us in federal prison. --- 110 unchanged lines hidden (view full) --- 166 167static void *dlhandle; 168 169#ifndef _PATH_USRLIB 170#define _PATH_USRLIB "/usr/lib" 171#endif 172 173#ifndef LIBDES |
174#ifdef OBJFORMAT_ELF 175#define LIBDES "libdes.so.3" 176#else |
|
174#define LIBDES "libdes.so.3." | 177#define LIBDES "libdes.so.3." |
178#endif /* OBJFORMAT_ELF */ |
|
175#endif 176 177void load_des(warn, libpath) 178 int warn; 179 char *libpath; 180{ 181 DIR *dird; 182 struct dirent *dirp; 183 char dlpath[MAXPATHLEN]; 184 int minor = -1; 185 int len; 186 187 if (libpath == NULL) { | 179#endif 180 181void load_des(warn, libpath) 182 int warn; 183 char *libpath; 184{ 185 DIR *dird; 186 struct dirent *dirp; 187 char dlpath[MAXPATHLEN]; 188 int minor = -1; 189 int len; 190 191 if (libpath == NULL) { |
192#ifdef OBJFORMAT_ELF 193 snprintf(dlpath, sizeof(dlpath), "%s/%s", _PATH_USRLIB, LIBDES); 194#else |
|
188 len = strlen(LIBDES); 189 if ((dird = opendir(_PATH_USRLIB)) == NULL) 190 err(1, "opendir(/usr/lib) failed"); 191 192 while ((dirp = readdir(dird)) != NULL) { 193 /* must have a minor number */ 194 if (strlen(dirp->d_name) <= len) 195 continue; 196 if (!strncmp(dirp->d_name, LIBDES, len)) { 197 if (atoi((dirp->d_name + len + 1)) > minor) { 198 minor = atoi((dirp->d_name + len + 1)); 199 snprintf(dlpath,sizeof(dlpath),"%s/%s", 200 _PATH_USRLIB, dirp->d_name); 201 } 202 } 203 } 204 205 closedir(dird); | 195 len = strlen(LIBDES); 196 if ((dird = opendir(_PATH_USRLIB)) == NULL) 197 err(1, "opendir(/usr/lib) failed"); 198 199 while ((dirp = readdir(dird)) != NULL) { 200 /* must have a minor number */ 201 if (strlen(dirp->d_name) <= len) 202 continue; 203 if (!strncmp(dirp->d_name, LIBDES, len)) { 204 if (atoi((dirp->d_name + len + 1)) > minor) { 205 minor = atoi((dirp->d_name + len + 1)); 206 snprintf(dlpath,sizeof(dlpath),"%s/%s", 207 _PATH_USRLIB, dirp->d_name); 208 } 209 } 210 } 211 212 closedir(dird); |
213#endif /* OBJFORMAT_ELF */ |
|
206 } else 207 snprintf(dlpath, sizeof(dlpath), "%s", libpath); 208 209 if (dlpath != NULL && (dlhandle = dlopen(dlpath, 0444)) != NULL) | 214 } else 215 snprintf(dlpath, sizeof(dlpath), "%s", libpath); 216 217 if (dlpath != NULL && (dlhandle = dlopen(dlpath, 0444)) != NULL) |
218#ifdef OBJFORMAT_ELF 219 _my_crypt = (int (*)())dlsym(dlhandle, "_des_crypt"); 220#else |
|
210 _my_crypt = (int (*)())dlsym(dlhandle, "__des_crypt"); | 221 _my_crypt = (int (*)())dlsym(dlhandle, "__des_crypt"); |
222#endif /* OBJFORMAT_ELF */ |
|
211 212 if (_my_crypt == NULL) { 213 if (dlhandle != NULL) 214 dlclose(dlhandle); 215 _my_crypt = &_arcfour_crypt; 216 if (warn) { 217 printf ("DES support disabled -- using ARCFOUR instead.\n"); 218 printf ("Warning: ARCFOUR cipher is not compatible with "); --- 79 unchanged lines hidden --- | 223 224 if (_my_crypt == NULL) { 225 if (dlhandle != NULL) 226 dlclose(dlhandle); 227 _my_crypt = &_arcfour_crypt; 228 if (warn) { 229 printf ("DES support disabled -- using ARCFOUR instead.\n"); 230 printf ("Warning: ARCFOUR cipher is not compatible with "); --- 79 unchanged lines hidden --- |