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