]> diplodocus.org Git - nmh/blob - config/config.c
mhlsbr.c: Don't strchr(3) non-string NUL-less buffer.
[nmh] / config / config.c
1 /* config.c -- master nmh configuration file
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include <h/mh.h>
9 #include "sbr/m_maildir.h"
10 #include <pwd.h>
11
12 #define nmhbindir(file) NMHBINDIR#file
13 #define nmhlibexecdir(file) NMHLIBEXECDIR#file
14 #define nmhetcdir(file) NMHETCDIR#file
15
16
17 /*
18 * Find the location of a format or configuration
19 * file, and return its absolute pathname.
20 *
21 * 1) If already absolute pathname, then leave unchanged.
22 * 2) Next, if it begins with ~user, then expand it.
23 * 3) Next, check in nmh Mail directory.
24 * 4) Next, check in nmh `etc' directory.
25 *
26 */
27
28 char *
29 etcpath (char *file)
30 {
31 static char epath[PATH_MAX];
32 char *cp;
33 char *pp;
34 struct passwd *pw;
35
36 context_read();
37
38 switch (*file) {
39 case '/':
40 /* If already absolute pathname, return it */
41 return file;
42
43 case '~':
44 /* Expand ~username */
45 if ((cp = strchr(pp = file + 1, '/')))
46 *cp++ = '\0';
47 if (*pp == '\0') {
48 pp = mypath;
49 } else {
50 if ((pw = getpwnam (pp)))
51 pp = pw->pw_dir;
52 else {
53 if (cp)
54 *--cp = '/';
55 goto try_it;
56 }
57 }
58
59 snprintf (epath, sizeof(epath), "%s/%s", pp, FENDNULL(cp));
60 if (cp)
61 *--cp = '/';
62
63 if (access (epath, R_OK) != NOTOK)
64 return epath;
65
66 /* FALLTHRU */
67 try_it:
68 default:
69 /* Check nmh Mail directory */
70 if (access ((cp = m_mailpath (file)), R_OK) != NOTOK) {
71 /* Will leak because caller doesn't know cp was
72 dynamically allocated. */
73 return cp;
74 }
75 free (cp);
76 }
77
78 /* Check nmh `etc' directory */
79 snprintf (epath, sizeof(epath), nmhetcdir(/%s), file);
80 return access(epath, R_OK) != NOTOK ? epath : file;
81 }
82
83
84 /*
85 * Standard yes/no switches structure
86 */
87
88 struct swit anoyes[] = {
89 { "no", 0, 0 },
90 { "yes", 0, 1 },
91 { NULL, 0, 0 }
92 };
93
94 /*
95 * nmh constants
96 */
97
98 /* initial profile for new users */
99 char *mh_defaults = nmhetcdir (/mh.profile);
100
101 /* default name of user profile */
102 char *mh_profile = ".mh_profile";
103
104 /* name of credentials file, defaults to .netrc in either Path or $HOME. */
105 char *credentials_file;
106
107 /* if set to 1, do not check permissions on credentials file */
108 int credentials_no_perm_check = 0;
109
110 /* name of current message "sequence" */
111 char *current = "cur";
112
113 /* standard component files */
114 char *components = "components"; /* comp */
115 char *replcomps = "replcomps"; /* repl */
116 char *replgroupcomps = "replgroupcomps"; /* repl -group */
117 char *forwcomps = "forwcomps"; /* forw */
118 char *distcomps = "distcomps"; /* dist */
119 char *rcvdistcomps = "rcvdistcomps"; /* rcvdist */
120 char *digestcomps = "digestcomps"; /* forw -digest */
121
122 /* standard format (filter) files */
123 char *mhlformat = "mhl.format"; /* show */
124 char *mhlreply = "mhl.reply"; /* repl -filter */
125 char *mhlforward = "mhl.forward"; /* forw -filter */
126
127 char *draft = "draft";
128
129 char *inbox = "Inbox";
130 char *defaultfolder = "inbox";
131
132 char *pfolder = "Current-Folder";
133 char *usequence = "Unseen-Sequence";
134 char *psequence = "Previous-Sequence";
135 char *nsequence = "Sequence-Negation";
136
137 /* profile entries for storage locations */
138 char *nmhstorage = "nmh-storage";
139 char *nmhcache = "nmh-cache";
140 char *nmhprivcache = "nmh-private-cache";
141
142 /* profile entry for external ftp access command */
143 char *nmhaccessftp = "nmh-access-ftp";
144
145 /* profile entry for external url access command */
146 char *nmhaccessurl = "nmh-access-url";
147
148 char *mhbindir = NMHBINDIR;
149 char *mhlibexecdir = NMHLIBEXECDIR;
150 char *mhetcdir = NMHETCDIR;
151 char *mhdocdir = NMHDOCDIR;
152
153 /*
154 * nmh not-so constants
155 */
156
157 /*
158 * Default name for the nmh context file.
159 */
160 char *context = "context";
161
162 /*
163 * Default name of file for public sequences. If "\0" (an empty
164 * "mh-sequences" profile entry), then nmh will use private sequences by
165 * default.
166 */
167 char *mh_seq = ".mh_sequences";
168
169 /*
170 * nmh globals
171 */
172
173 char ctxflags; /* status of user's context */
174 char *invo_name; /* command invocation name */
175 char *mypath; /* user's $HOME */
176 char *defpath; /* pathname of user's profile */
177 char *ctxpath; /* pathname of user's context */
178 struct node *m_defs; /* profile/context structure */
179
180 /*
181 * nmh processes
182 */
183
184 /*
185 * This is the program to process MIME composition files
186 */
187 char *buildmimeproc = nmhbindir (/mhbuild);
188 /*
189 * This is the program to `cat' a file.
190 */
191 char *catproc = "/bin/cat";
192
193 /*
194 * This program is usually called directly by users, but it is
195 * also invoked by the post program to process an "Fcc", or by
196 * comp/repl/forw/dist to refile a draft message.
197 */
198
199 char *fileproc = nmhbindir (/refile);
200
201 /*
202 * This program is used to optionally format the bodies of messages by
203 * "mhl".
204 */
205
206 char *formatproc = NULL;
207
208 /*
209 * This program is called to incorporate messages into a folder.
210 */
211
212 char *incproc = nmhbindir (/inc);
213
214 /*
215 * This is the default program invoked by a "list" response
216 * at the "What now?" prompt. It is also used by the draft
217 * folder facility in comp/dist/forw/repl to display the
218 * draft message.
219 */
220
221 char *lproc = NULL;
222
223 /*
224 * This is the path for the Bell equivalent mail program.
225 */
226
227 char *mailproc = nmhbindir (/mhmail);
228
229 /*
230 * This is used by mhl as a front-end. It is also used
231 * by mhn as the default method of displaying message bodies
232 * or message parts of type text/plain.
233 */
234
235 char *moreproc = NULL;
236
237 /*
238 * This is the program (mhl) used to filter messages. It is
239 * used by mhn to filter and display the message headers of
240 * MIME messages. It is used by repl/forw (with -filter)
241 * to filter the message to which you are replying/forwarding.
242 * It is used by send/post (with -filter) to filter the message
243 * for "Bcc:" recipients.
244 */
245
246 char *mhlproc = nmhlibexecdir (/mhl);
247
248 /*
249 * This program is called to pack a folder.
250 */
251
252 char *packproc = nmhbindir (/packf);
253
254 /*
255 * This is the delivery program called by send to actually
256 * deliver mail to users. This is the interface to the MTS.
257 */
258
259 char *postproc = nmhlibexecdir (/post);
260
261 /*
262 * This is program is called by slocal to handle
263 * the action `folder' or `+'.
264 */
265
266 char *rcvstoreproc = nmhlibexecdir (/rcvstore);
267
268 /*
269 * This program is called to remove a message by rmm or refile -nolink.
270 * It's usually empty, which means to rename the file to a backup name.
271 */
272
273 char *rmmproc = NULL;
274
275 /*
276 * This program is usually called by the user's whatnowproc, but it
277 * may also be called directly to send a message previously composed.
278 */
279
280 char *sendproc = nmhbindir (/send);
281
282 /*
283 * This is the path to the program used by "show"
284 * to display non-text (MIME) messages.
285 */
286
287 char *showmimeproc = nmhbindir (/mhshow);
288
289 /*
290 * This is the default program called by "show" to filter
291 * and display standard text (non-MIME) messages. It can be
292 * changed to a pager (such as "more" or "less") if you prefer
293 * that such message not be filtered in any way.
294 */
295
296 char *showproc = nmhlibexecdir (/mhl);
297
298 /*
299 * This program is called after comp, et. al., have built a draft
300 */
301
302 char *whatnowproc = nmhbindir (/whatnow);
303
304 /*
305 * This program is called to list/validate the addresses in a message.
306 */
307
308 char *whomproc = nmhbindir (/whom);
309
310 /*
311 * This is the global nmh alias file. It is somewhat obsolete, since
312 * global aliases should be handled by the Mail Transport Agent (MTA).
313 */
314
315 char *AliasFile = nmhetcdir (/MailAliases);
316
317 /*
318 * File protections
319 */
320
321 /*
322 * Folders (directories) are created with this protection (mode)
323 */
324
325 char *foldprot = "700";
326
327 /*
328 * Every NEW message will be created with this protection. When a
329 * message is filed it retains its protection, so this only applies
330 * to messages coming in through inc.
331 */
332
333 char *msgprot = "600";