]> andersk Git - gssapi-openssh.git/blame - openssh/pathnames.c
#include <stdlib.h> for getenv().
[gssapi-openssh.git] / openssh / pathnames.c
CommitLineData
ae43c103 1#include "includes.h"
2#include "xmalloc.h"
3#include "log.h"
4
16ea2b98 5#include <string.h>
5734d9a2 6#include <stdlib.h>
16ea2b98 7
ae43c103 8#define BINDIR "/bin"
9#define LIBEXEC "/libexec"
10#define SSHDIR "/etc/ssh"
d7766c89 11#define VARDIR "/var"
ae43c103 12
a81d7068 13#define STRINIT "init_pathnames() not called!"
14
15char *SSH_PRNG_COMMAND_FILE = STRINIT;
16char *_PATH_SSH_SYSTEM_HOSTFILE = STRINIT;
17char *_PATH_SSH_SYSTEM_HOSTFILE2 = STRINIT;
18char *_PATH_SERVER_CONFIG_FILE = STRINIT;
19char *_PATH_HOST_CONFIG_FILE = STRINIT;
20char *_PATH_HOST_KEY_FILE = STRINIT;
21char *_PATH_HOST_DSA_KEY_FILE = STRINIT;
22char *_PATH_HOST_RSA_KEY_FILE = STRINIT;
23char *_PATH_DH_MODULI = STRINIT;
24char *_PATH_DH_PRIMES = STRINIT;
25char *_PATH_SSH_PROGRAM = STRINIT;
d7766c89 26char *_PATH_SSH_DAEMON_PID_FILE = STRINIT;
a81d7068 27char *_PATH_SSH_SYSTEM_RC = STRINIT;
28char *_PATH_SSH_HOSTS_EQUIV = STRINIT;
b2393c9a 29char *_PATH_SSH_KEY_SIGN = STRINIT;
a81d7068 30char *_PATH_SFTP_SERVER = STRINIT;
31char *SSH_RAND_HELPER = STRINIT;
32char *_PATH_STDPATH_WITH_SCP = STRINIT;
ae43c103 33
34static char *
a81d7068 35compose3(const char str1[], const char str2[], const char str3[])
ae43c103 36{
37 int len;
38 char *result;
39
40 len = strlen(str1) + strlen(str2) + strlen(str3) + 1;
41 result = xmalloc(len);
42 snprintf(result, len, "%s%s%s", str1, str2, str3);
43
44 return result;
45}
46
a81d7068 47static char *
48compose4(const char str1[], const char str2[], const char str3[],
49 const char str4[])
50{
51 int len;
52 char *result;
53
54 len = strlen(str1) + strlen(str2) + strlen(str3) + strlen(str4) + 1;
55 result = xmalloc(len);
56 snprintf(result, len, "%s%s%s%s", str1, str2, str3, str4);
57
58 return result;
59}
60
ae43c103 61void
62init_pathnames()
63{
64 char *gl;
65
bd15369a 66 gl = (char *)getenv("GLOBUS_LOCATION");
67 if (gl == (char *)NULL) {
ae43c103 68 fatal("GLOBUS_LOCATION environment variable undefined.");
69 }
70
a81d7068 71 /* lots of one time memory leaks here */
72 SSH_PRNG_COMMAND_FILE = compose3(gl, SSHDIR, "/ssh_prng_cmds");
73 _PATH_SSH_SYSTEM_HOSTFILE = compose3(gl, SSHDIR, "/ssh_known_hosts");
74 _PATH_SSH_SYSTEM_HOSTFILE2 = compose3(gl, SSHDIR, "/ssh_known_hosts2");
75 _PATH_SERVER_CONFIG_FILE = compose3(gl, SSHDIR, "/sshd_config");
76 _PATH_HOST_CONFIG_FILE = compose3(gl, SSHDIR, "/ssh_config");
77 _PATH_HOST_KEY_FILE = compose3(gl, SSHDIR, "/ssh_host_key");
78 _PATH_HOST_DSA_KEY_FILE = compose3(gl, SSHDIR, "/ssh_host_dsa_key");
79 _PATH_HOST_RSA_KEY_FILE = compose3(gl, SSHDIR, "/ssh_host_rsa_key");
80 _PATH_DH_MODULI = compose3(gl, SSHDIR, "/moduli");
81 _PATH_DH_PRIMES = compose3(gl, SSHDIR, "/primes");
5d0b2e48 82 _PATH_SSH_PROGRAM = compose3(gl, BINDIR, "/gsissh");
d7766c89 83 _PATH_SSH_DAEMON_PID_FILE = compose3(gl, VARDIR, "/sshd.pid");
a81d7068 84 _PATH_SSH_SYSTEM_RC = compose3(gl, SSHDIR, "/sshrc");
85 _PATH_SSH_HOSTS_EQUIV = compose3(gl, SSHDIR, "/shosts.equiv");
b2393c9a 86 _PATH_SSH_KEY_SIGN = compose3(gl, LIBEXEC, "/ssh-keysign");
a81d7068 87 _PATH_SFTP_SERVER = compose3(gl, LIBEXEC, "/sftp-server");
88 SSH_RAND_HELPER = compose3(gl, LIBEXEC, "/ssh-rand-helper");
89 _PATH_STDPATH_WITH_SCP = compose4(_PATH_STDPATH, ":", gl, BINDIR);
ae43c103 90}
This page took 0.067351 seconds and 5 git commands to generate.