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