[Git][NTPsec/ntpsec][master] 2 commits: Remove some unused code in ntpkeygen().
Eric S. Raymond
gitlab at mg.gitlab.com
Wed Aug 10 12:50:09 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
f994d514 by Eric S. Raymond at 2016-08-10T08:36:14-04:00
Remove some unused code in ntpkeygen().
- - - - -
b591c41b by Eric S. Raymond at 2016-08-10T08:49:56-04:00
In ntpkeygen, remove an obsolete Windows compatibility shim.
This was an ugly hack to get around the absence of symlink(2). It was
obsolete because versions since Vista (2007) have a CreateSymbolicLink()
function which we can trivially plug in if and when we repair the
Windows port.
- - - - -
1 changed file:
- ntpkeygen/ntpkeygen.c
Changes:
=====================================
ntpkeygen/ntpkeygen.c
=====================================
--- a/ntpkeygen/ntpkeygen.c
+++ b/ntpkeygen/ntpkeygen.c
@@ -43,7 +43,6 @@
#include <openssl/objects.h>
#endif /* HAVE_OPENSSL */
#include <sodium.h>
-#include <ssl_applink.c>
/*
* Cryptodefines
@@ -56,7 +55,6 @@
*/
FILE *fheader (const char *, const char *, const char *);
bool gen_md5 (const char *);
-void followlink (char *, size_t);
/*
* Program variables
@@ -70,111 +68,6 @@ char *hostname = NULL; /* host, used in cert filenames */
char *groupname = NULL; /* group name */
char filename[MAXFILENAME + 1]; /* file name */
-#ifdef SYS_WINNT
-BOOL init_randfile();
-
-/*
- * Don't try to follow symbolic links on Windows. Assume link == file.
- */
-int
-readlink(
- char * link,
- char * file,
- int len
- )
-{
- return strlen(file);
-}
-
-/*
- * Don't try to create symbolic links on Windows, that is supported on
- * Vista and later only. Instead, if CreateHardLink is available (XP
- * and later), hardlink the linkname to the original filename. On
- * earlier systems, user must rename file to match expected link for
- * ntpd to find it. To allow building a ntpkeygen.exe which loads on
- * Windows pre-XP, runtime link to CreateHardLinkA().
- */
-int
-symlink(
- char * filename,
- char* linkname
- )
-{
- typedef BOOL (WINAPI *PCREATEHARDLINKA)(
- __in LPCSTR lpFileName,
- __in LPCSTR lpExistingFileName,
- __reserved LPSECURITY_ATTRIBUTES lpSA
- );
- static PCREATEHARDLINKA pCreateHardLinkA;
- static int tried;
- HMODULE hDll;
- FARPROC pfn;
- int link_created;
- int saved_errno;
-
- if (!tried) {
- tried = TRUE;
- hDll = LoadLibrary("kernel32");
- pfn = GetProcAddress(hDll, "CreateHardLinkA");
- pCreateHardLinkA = (PCREATEHARDLINKA)pfn;
- }
-
- if (NULL == pCreateHardLinkA) {
- errno = ENOSYS;
- return -1;
- }
-
- link_created = (*pCreateHardLinkA)(linkname, filename, NULL);
-
- if (link_created)
- return 0;
-
- saved_errno = GetLastError(); /* yes we play loose */
- mfprintf(stderr, "Create hard link %s to %s failed: %m\n",
- linkname, filename);
- errno = saved_errno;
- return -1;
-}
-
-void
-InitWin32Sockets() {
- WORD wVersionRequested;
- WSADATA wsaData;
- wVersionRequested = MAKEWORD(2,0);
- if (WSAStartup(wVersionRequested, &wsaData))
- {
- fprintf(stderr, "No useable winsock.dll\n");
- exit(1);
- }
-}
-#endif /* SYS_WINNT */
-
-
-/*
- * followlink() - replace filename with its target if symlink.
- *
- * Some readlink() implementations do not null-terminate the result.
- */
-void
-followlink(
- char * fname,
- size_t bufsiz
- )
-{
- int len;
-
- REQUIRE(bufsiz > 0);
-
- len = readlink(fname, fname, (int)bufsiz);
- if (len < 0 ) {
- fname[0] = '\0';
- return;
- }
- if (len > (int)bufsiz - 1)
- len = (int)bufsiz - 1;
- fname[len] = '\0';
-}
-
#define ALL_OPTIONS "Mh"
static const struct option longoptions[] = {
{ "md5key", 0, 0, 'M' },
@@ -198,14 +91,6 @@ main(
init_lib();
-#ifdef SYS_WINNT
- /* Initialize before OpenSSL checks */
- InitWin32Sockets();
- if (!init_randfile())
- fprintf(stderr, "Unable to initialize .rnd file\n");
- ssl_applink();
-#endif
-
#ifdef HAVE_OPENSSL
ssl_check_version();
#endif /* HAVE_OPENSSL */
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/eaafa8306210c9dc43d9d2b6f2dbf468ea9e9b14...b591c41b30be19e320a8c9f4469dddda2f5dac73
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160810/9ba55bcb/attachment.html>
More information about the vc
mailing list