Commit 54415d85f1bbe99a1740cbad8ec7727c205c913b

Tracey Emery 2020-01-15T22:10:31

kn@ and stsp@ suggested changes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
diff --git a/Makefile b/Makefile
index ed241a5..485f779 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,10 @@ SUBDIR = libexec got tog
 .PHONY: release dist
 
 .if make(regress) || make(obj) || make(clean) || make(release)
-SUBDIR += regress gotweb
+SUBDIR += regress
+# not part of original SUBDIR, since we don't build gotweb by default and
+# the port will be split into sub packages
+SUBDIR += gotweb
 .endif
 
 .include "got-version.mk"
@@ -26,13 +29,9 @@ dist: clean
 	rm got-dist.txt.new
 
 web:
-	sed -i -e "s/MAKEWEB=No/MAKEWEB=Yes/" got-version.mk
-	${MAKE} -C gotweb
-	sed -i -e "s/MAKEWEB=Yes/MAKEWEB=No/" got-version.mk
+	${MAKE} -C gotweb MAKEWEB=Yes
 
 web-install:
-	sed -i -e "s/MAKEWEB=No/MAKEWEB=Yes/" got-version.mk
-	${MAKE} -C gotweb install
-	sed -i -e "s/MAKEWEB=Yes/MAKEWEB=No/" got-version.mk
+	${MAKE} -C gotweb install MAKEWEB=Yes
 
 .include <bsd.subdir.mk>
diff --git a/Makefile.inc b/Makefile.inc
index 92bb0fe..5952e3a 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -28,7 +28,7 @@ DEBUG = -O0 -g
 
 .endif
 
-.if ${MAKEWEB} == "Yes"
+.if "${MAKEWEB}" == "Yes"
 LDADD =		-L${PREFIX}/lib -static -lkcgihtml -lkcgi -lz -lutil
 PREFIX =	/usr/local
 CHROOT_DIR =	/var/www
@@ -42,4 +42,6 @@ TMP_DIR =	${CHROOT_DIR}/tmp
 PROG_DIR =	${HTTPD_DIR}/${PROG}
 CGI_DIR =	${CHROOT_DIR}${GOTWEB_DIR}
 TMPL_DIR =	${CGI_DIR}/gw_tmpl
+WWWUSR ?=	www
+WWWGRP ?=	www
 .endif
diff --git a/gotweb/Makefile b/gotweb/Makefile
index c865312..fd425d0 100644
--- a/gotweb/Makefile
+++ b/gotweb/Makefile
@@ -25,28 +25,31 @@ realinstall:
 	if [ ! -d ${CGI_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${CGI_DIR}; \
 	fi
-	${INSTALL} -c -o www -g www -m 0755 ${PROG} ${CGI_DIR}/${PROG}
+	${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 ${PROG} \
+	    ${CGI_DIR}/${PROG}
 	if [ ! -d ${TMPL_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${TMPL_DIR}; \
 	fi
-	${INSTALL} -c -o www -g www -m 0755 files/cgi-bin/gw_tmpl/* ${TMPL_DIR}
+	${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 \
+	    files/cgi-bin/gw_tmpl/* ${TMPL_DIR}
 	if [ ! -d ${ETC_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${ETC_DIR}; \
 	fi
 	if [ ! -d ${EXPL_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${EXPL_DIR}; \
 	fi
-	${INSTALL} -c -o www -g www -m 0755 files/etc/gotweb.conf \
+	${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 files/etc/gotweb.conf \
 		${ETC_DIR}/examples/gotweb.conf
 	if [ ! -d ${HTTPD_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${HTTPD_DIR}; \
 	fi
 	if [ ! -d ${TMP_DIR}/. ]; then \
-		${INSTALL} -d -o www -g www -m 755 ${TMP_DIR}; \
+		${INSTALL} -d -o ${WWWUSR} -g ${WWWGRP} -m 755 ${TMP_DIR}; \
 	fi
 	if [ ! -d ${PROG_DIR}/. ]; then \
 		${INSTALL} -d -o root -g daemon -m 755 ${PROG_DIR}; \
 	fi
-	${INSTALL} -c -o www -g www -m 0755 files/htdocs/${PROG}/* ${PROG_DIR}
+	${INSTALL} -c -o ${WWWUSR} -g ${WWWGRP} -m 0755 files/htdocs/${PROG}/* \
+	    ${PROG_DIR}
 
 .include <bsd.prog.mk>
diff --git a/gotweb/README b/gotweb/README
index c63ca83..af0950e 100644
--- a/gotweb/README
+++ b/gotweb/README
@@ -18,13 +18,6 @@ Man page files in the Gotweb source tree can be viewed with 'man -l':
 
  $ man -l gotweb/gotweb.conf.5
 
-Guidelines for reporting problems:
-
-Report all Gotweb problems in as much detail as possible. Gotweb code is not
-covered by automated tests.
-
-Mail problem reports to: gameoftrees@openbsd.org
-
 Example configuration for httpd.conf:
 
 ext_if = "*"
@@ -51,7 +44,6 @@ Mail patches to: gameoftrees@openbsd.org
 Pull requests via any Git hosting sites will likely be overlooked.
 Please keep the intended target audience in mind when contributing to Gotweb.
 
-
 Subscribing to the gameoftrees@openbsd.org mailing list:
 
 The mailing list is used for patch reviews, bug reports, and user questions.
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index b97f4ea..e9bf111 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -53,7 +53,7 @@
 #define nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
 #endif
 
-struct trans {
+struct gw_trans {
 	TAILQ_HEAD(dirs, gw_dir) gw_dirs;
 	struct gw_dir		*gw_dir;
 	struct gotweb_conf	*gw_conf;
@@ -94,7 +94,7 @@ struct gw_dir {
 	char			*path;
 };
 
-enum tmpl {
+enum gw_tmpl {
 	TEMPL_HEAD,
 	TEMPL_HEADER,
 	TEMPL_SITEPATH,
@@ -105,12 +105,12 @@ enum tmpl {
 	TEMPL__MAX
 };
 
-enum ref_tm {
+enum gw_ref_tm {
 	TM_DIFF,
 	TM_LONG,
 };
 
-enum logs {
+enum gw_logs {
 	LOGBRIEF,
 	LOGCOMMIT,
 	LOGFULL,
@@ -120,18 +120,12 @@ enum logs {
 	LOGTAG,
 };
 
-enum tags {
+enum gw_tags {
 	TAGBRIEF,
 	TAGFULL,
 };
 
-struct buf {
-	u_char	*cb_buf;
-	size_t	 cb_size;
-	size_t	 cb_len;
-};
-
-static const char *const templs[TEMPL__MAX] = {
+static const char *const gw_templs[TEMPL__MAX] = {
 	"head",
 	"header",
 	"sitepath",
@@ -151,42 +145,44 @@ static const struct kvalid gw_keys[KEY__ZMAX] = {
 	{ kvalid_stringne,	"path" },
 };
 
-int				 gw_get_repo_log_count(struct trans *, char *);
+int				 gw_get_repo_log_count(struct gw_trans *, char *);
 
 static struct gw_dir		*gw_init_gw_dir(char *);
 
-static char			*gw_get_repo_description(struct trans *,
+static char			*gw_get_repo_description(struct gw_trans *,
 				    char *);
-static char			*gw_get_repo_owner(struct trans *,
+static char			*gw_get_repo_owner(struct gw_trans *,
 				    char *);
 static char			*gw_get_time_str(time_t, int);
-static char			*gw_get_repo_age(struct trans *,
+static char			*gw_get_repo_age(struct gw_trans *,
 				    char *, char *, int);
-static char			*gw_get_repo_log(struct trans *, const char *,
+static char			*gw_get_repo_log(struct gw_trans *, const char *,
 				    char *, int, int);
-static char			*gw_get_file_blame(struct trans *, char *);
-static char			*gw_get_repo_tree(struct trans *, char *);
-static char			*gw_get_repo_diff(struct trans *, char *,
+static char			*gw_get_file_blame(struct gw_trans *, char *);
+static char			*gw_get_repo_tree(struct gw_trans *, char *);
+static char			*gw_get_repo_diff(struct gw_trans *, char *,
 				    char *);
-static char			*gw_get_repo_tags(struct trans *, int, int);
-static char			*gw_get_repo_heads(struct trans *);
-static char			*gw_get_clone_url(struct trans *, char *);
-static char			*gw_get_got_link(struct trans *);
-static char			*gw_get_site_link(struct trans *);
+static char			*gw_get_repo_tags(struct gw_trans *, int, int);
+static char			*gw_get_repo_heads(struct gw_trans *);
+static char			*gw_get_clone_url(struct gw_trans *, char *);
+static char			*gw_get_got_link(struct gw_trans *);
+static char			*gw_get_site_link(struct gw_trans *);
 static char			*gw_html_escape(const char *);
 static char			*color_diff_line(char *);
 
-static void			 gw_display_open(struct trans *, enum khttp,
+static void			 gw_display_open(struct gw_trans *, enum khttp,
 				    enum kmime);
-static void			 gw_display_index(struct trans *,
+static void			 gw_display_index(struct gw_trans *,
 				    const struct got_error *);
 
 static int			 gw_template(size_t, void *);
 
-static const struct got_error*	 apply_unveil(const char *, const char *);
+static const struct got_error*	 gw_apply_unveil(const char *, const char *);
 static const struct got_error*	 cmp_tags(void *, int *,
 				    struct got_reference *,
 				    struct got_reference *);
+
+/* got_repo_resolve_commit_arg */
 static const struct got_error*	 resolve_commit_arg(struct got_object_id **,
 				    const char *, struct got_repository *);
 static const struct got_error*	 match_object_id(struct got_object_id **,
@@ -194,28 +190,28 @@ static const struct got_error*	 match_object_id(struct got_object_id **,
 				    struct got_repository *);
 static const struct got_error*	 blame_cb(void *, int, int,
 				    struct got_object_id *);
-static const struct got_error*	 gw_load_got_paths(struct trans *);
-static const struct got_error*	 gw_load_got_path(struct trans *,
+static const struct got_error*	 gw_load_got_paths(struct gw_trans *);
+static const struct got_error*	 gw_load_got_path(struct gw_trans *,
 				    struct gw_dir *);
-static const struct got_error*	 gw_parse_querystring(struct trans *);
+static const struct got_error*	 gw_parse_querystring(struct gw_trans *);
 static const struct got_error*	 match_logmsg(int *, struct got_object_id *,
 				    struct got_commit_object *, regex_t *);
 
-static const struct got_error*	 gw_blame(struct trans *);
-static const struct got_error*	 gw_commit(struct trans *);
-static const struct got_error*	 gw_commitdiff(struct trans *);
-static const struct got_error*	 gw_index(struct trans *);
-static const struct got_error*	 gw_log(struct trans *);
-static const struct got_error*	 gw_raw(struct trans *);
-static const struct got_error*	 gw_logbriefs(struct trans *);
-static const struct got_error*	 gw_summary(struct trans *);
-static const struct got_error*	 gw_tag(struct trans *);
-static const struct got_error*	 gw_tree(struct trans *);
+static const struct got_error*	 gw_blame(struct gw_trans *);
+static const struct got_error*	 gw_commit(struct gw_trans *);
+static const struct got_error*	 gw_commitdiff(struct gw_trans *);
+static const struct got_error*	 gw_index(struct gw_trans *);
+static const struct got_error*	 gw_log(struct gw_trans *);
+static const struct got_error*	 gw_raw(struct gw_trans *);
+static const struct got_error*	 gw_logbriefs(struct gw_trans *);
+static const struct got_error*	 gw_summary(struct gw_trans *);
+static const struct got_error*	 gw_tag(struct gw_trans *);
+static const struct got_error*	 gw_tree(struct gw_trans *);
 
 struct gw_query_action {
 	unsigned int		 func_id;
 	const char		*func_name;
-	const struct got_error	*(*func_main)(struct trans *);
+	const struct got_error	*(*func_main)(struct gw_trans *);
 	char			*template;
 };
 
@@ -248,7 +244,7 @@ static struct gw_query_action gw_query_funcs[] = {
 };
 
 static const struct got_error *
-apply_unveil(const char *repo_path, const char *repo_file)
+gw_apply_unveil(const char *repo_path, const char *repo_file)
 {
 	const struct got_error *err;
 
@@ -414,7 +410,7 @@ done:
 }
 
 int
-gw_get_repo_log_count(struct trans *gw_trans, char *start_commit)
+gw_get_repo_log_count(struct gw_trans *gw_trans, char *start_commit)
 {
 	const struct got_error *error;
 	struct got_repository *repo = NULL;
@@ -553,13 +549,13 @@ done:
 }
 
 static const struct got_error *
-gw_blame(struct trans *gw_trans)
+gw_blame(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -576,12 +572,12 @@ gw_blame(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_commit(struct trans *gw_trans)
+gw_commit(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -598,12 +594,12 @@ gw_commit(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_commitdiff(struct trans *gw_trans)
+gw_commitdiff(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -620,14 +616,14 @@ gw_commitdiff(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_index(struct trans *gw_trans)
+gw_index(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	struct gw_dir *gw_dir = NULL;
 	char *html, *navs, *next, *prev;
 	unsigned int prev_disp = 0, next_disp = 1, dir_c = 0;
 
-	error = apply_unveil(gw_trans->gw_conf->got_repos_path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_conf->got_repos_path, NULL);
 	if (error)
 		return error;
 
@@ -712,12 +708,12 @@ gw_index(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_log(struct trans *gw_trans)
+gw_log(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -735,7 +731,7 @@ gw_log(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_raw(struct trans *gw_trans)
+gw_raw(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 
@@ -743,12 +739,12 @@ gw_raw(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_logbriefs(struct trans *gw_trans)
+gw_logbriefs(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -767,14 +763,14 @@ gw_logbriefs(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_summary(struct trans *gw_trans)
+gw_summary(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *description_html, *repo_owner_html, *repo_age_html,
 	     *cloneurl_html, *log, *log_html, *tags, *heads, *tags_html,
 	     *heads_html, *age;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -863,12 +859,12 @@ gw_summary(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_tag(struct trans *gw_trans)
+gw_tag(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -885,12 +881,12 @@ gw_tag(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_tree(struct trans *gw_trans)
+gw_tree(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	char *log, *log_html;
 
-	error = apply_unveil(gw_trans->gw_dir->path, NULL);
+	error = gw_apply_unveil(gw_trans->gw_dir->path, NULL);
 	if (error)
 		return error;
 
@@ -907,7 +903,7 @@ gw_tree(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_load_got_path(struct trans *gw_trans, struct gw_dir *gw_dir)
+gw_load_got_path(struct gw_trans *gw_trans, struct gw_dir *gw_dir)
 {
 	const struct got_error *error = NULL;
 	DIR *dt;
@@ -964,7 +960,7 @@ errored:
 }
 
 static const struct got_error *
-gw_load_got_paths(struct trans *gw_trans)
+gw_load_got_paths(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	DIR *d;
@@ -1019,7 +1015,7 @@ gw_load_got_paths(struct trans *gw_trans)
 }
 
 static const struct got_error *
-gw_parse_querystring(struct trans *gw_trans)
+gw_parse_querystring(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	struct kpair *p;
@@ -1144,7 +1140,7 @@ done:
 }
 
 static void
-gw_display_open(struct trans *gw_trans, enum khttp code, enum kmime mime)
+gw_display_open(struct gw_trans *gw_trans, enum khttp code, enum kmime mime)
 {
 	khttp_head(gw_trans->gw_req, kresps[KRESP_ALLOW], "GET");
 	khttp_head(gw_trans->gw_req, kresps[KRESP_STATUS], "%s",
@@ -1158,7 +1154,7 @@ gw_display_open(struct trans *gw_trans, enum khttp code, enum kmime mime)
 }
 
 static void
-gw_display_index(struct trans *gw_trans, const struct got_error *err)
+gw_display_index(struct gw_trans *gw_trans, const struct got_error *err)
 {
 	gw_display_open(gw_trans, KHTTP_200, gw_trans->mime);
 	khtml_open(gw_trans->gw_html_req, gw_trans->gw_req, 0);
@@ -1176,7 +1172,7 @@ static int
 gw_template(size_t key, void *arg)
 {
 	const struct got_error *error = NULL;
-	struct trans *gw_trans = arg;
+	struct gw_trans *gw_trans = arg;
 	char *gw_got_link, *gw_site_link;
 	char *site_owner_name, *site_owner_name_h;
 
@@ -1236,7 +1232,7 @@ gw_template(size_t key, void *arg)
 }
 
 static char *
-gw_get_repo_description(struct trans *gw_trans, char *dir)
+gw_get_repo_description(struct gw_trans *gw_trans, char *dir)
 {
 	FILE *f;
 	char *description = NULL, *d_file = NULL;
@@ -1333,7 +1329,7 @@ gw_get_time_str(time_t committer_time, int ref_tm)
 }
 
 static char *
-gw_get_repo_age(struct trans *gw_trans, char *dir, char *repo_ref, int ref_tm)
+gw_get_repo_age(struct gw_trans *gw_trans, char *dir, char *repo_ref, int ref_tm)
 {
 	const struct got_error *error = NULL;
 	struct got_object_id *id = NULL;
@@ -1415,7 +1411,7 @@ err:
 }
 
 static char *
-gw_get_repo_diff(struct trans *gw_trans, char *id_str1, char *id_str2)
+gw_get_repo_diff(struct gw_trans *gw_trans, char *id_str1, char *id_str2)
 {
 	const struct got_error *error;
 	FILE *f = NULL;
@@ -1519,7 +1515,7 @@ done:
 }
 
 static char *
-gw_get_repo_owner(struct trans *gw_trans, char *dir)
+gw_get_repo_owner(struct gw_trans *gw_trans, char *dir)
 {
 	FILE *f;
 	char *owner = NULL, *d_file = NULL;
@@ -1578,7 +1574,7 @@ err:
 }
 
 static char *
-gw_get_clone_url(struct trans *gw_trans, char *dir)
+gw_get_clone_url(struct gw_trans *gw_trans, char *dir)
 {
 	FILE *f;
 	char *url = NULL, *d_file = NULL;
@@ -1604,7 +1600,7 @@ gw_get_clone_url(struct trans *gw_trans, char *dir)
 }
 
 static char *
-gw_get_repo_log(struct trans *gw_trans, const char *search_pattern,
+gw_get_repo_log(struct gw_trans *gw_trans, const char *search_pattern,
     char *start_commit, int limit, int log_type)
 {
 	const struct got_error *error;
@@ -2137,7 +2133,7 @@ done:
 }
 
 static char *
-gw_get_repo_tags(struct trans *gw_trans, int limit, int tag_type)
+gw_get_repo_tags(struct gw_trans *gw_trans, int limit, int tag_type)
 {
 	const struct got_error *error = NULL;
 	struct got_repository *repo = NULL;
@@ -2283,7 +2279,7 @@ struct blame_cb_args {
 	off_t *line_offsets;
 	FILE *f;
 	struct got_repository *repo;
-	struct trans *gw_trans;
+	struct gw_trans *gw_trans;
 	struct buf *blamebuf;
 };
 
@@ -2397,7 +2393,7 @@ done:
 }
 
 static char*
-gw_get_file_blame(struct trans *gw_trans, char *commit_str)
+gw_get_file_blame(struct gw_trans *gw_trans, char *commit_str)
 {
 	const struct got_error *error = NULL;
 	struct got_repository *repo = NULL;
@@ -2528,7 +2524,7 @@ done:
 }
 
 static char*
-gw_get_repo_tree(struct trans *gw_trans, char *commit_str)
+gw_get_repo_tree(struct gw_trans *gw_trans, char *commit_str)
 {
 	const struct got_error *error = NULL;
 	struct got_repository *repo = NULL;
@@ -2692,7 +2688,7 @@ done:
 }
 
 static char *
-gw_get_repo_heads(struct trans *gw_trans)
+gw_get_repo_heads(struct gw_trans *gw_trans)
 {
 	const struct got_error *error = NULL;
 	struct got_repository *repo = NULL;
@@ -2772,7 +2768,7 @@ done:
 }
 
 static char *
-gw_get_got_link(struct trans *gw_trans)
+gw_get_got_link(struct gw_trans *gw_trans)
 {
 	char *link;
 
@@ -2784,7 +2780,7 @@ gw_get_got_link(struct trans *gw_trans)
 }
 
 static char *
-gw_get_site_link(struct trans *gw_trans)
+gw_get_site_link(struct gw_trans *gw_trans)
 {
 	char *link, *repo = "", *action = "";
 
@@ -2918,12 +2914,12 @@ int
 main()
 {
 	const struct got_error *error = NULL;
-	struct trans *gw_trans;
+	struct gw_trans *gw_trans;
 	struct gw_dir *dir = NULL, *tdir;
 	const char *page = "index";
 	int gw_malloc = 1;
 
-	if ((gw_trans = malloc(sizeof(struct trans))) == NULL)
+	if ((gw_trans = malloc(sizeof(struct gw_trans))) == NULL)
 		errx(1, "malloc");
 
 	if ((gw_trans->gw_req = malloc(sizeof(struct kreq))) == NULL)
@@ -2960,7 +2956,7 @@ main()
 	gw_trans->commit = NULL;
 	gw_trans->headref = strdup(GOT_REF_HEAD);
 	gw_trans->mime = KMIME_TEXT_HTML;
-	gw_trans->gw_tmpl->key = templs;
+	gw_trans->gw_tmpl->key = gw_templs;
 	gw_trans->gw_tmpl->keysz = TEMPL__MAX;
 	gw_trans->gw_tmpl->arg = gw_trans;
 	gw_trans->gw_tmpl->cb = gw_template;
diff --git a/gotweb/parse.y b/gotweb/parse.y
index f066d2d..0101a26 100644
--- a/gotweb/parse.y
+++ b/gotweb/parse.y
@@ -105,35 +105,35 @@ boolean		: STRING			{
 		;
 
 main		: GOT_REPOS_PATH STRING {
-      			if ((gw_conf->got_repos_path = strdup($2)) == NULL)
+			if ((gw_conf->got_repos_path = strdup($2)) == NULL)
 				errx(1, "out of memory");
-      		}
+		}
 		| GOT_WWW_PATH STRING {
-      			if ((gw_conf->got_www_path = strdup($2)) == NULL)
+			if ((gw_conf->got_www_path = strdup($2)) == NULL)
 				errx(1, "out of memory");
-      		}
+		}
 		| GOT_MAX_REPOS NUMBER {
 			if ($2 > 0)
 				gw_conf->got_max_repos = $2;
 		}
 		| GOT_SITE_NAME STRING {
-      			if ((gw_conf->got_site_name = strdup($2)) == NULL)
+				if ((gw_conf->got_site_name = strdup($2)) == NULL)
 				errx(1, "out of memory");
 		}
 		| GOT_SITE_OWNER STRING {
-      			if ((gw_conf->got_site_owner = strdup($2)) == NULL)
+				if ((gw_conf->got_site_owner = strdup($2)) == NULL)
 				errx(1, "out of memory");
 		}
 		| GOT_SITE_LINK STRING {
-      			if ((gw_conf->got_site_link = strdup($2)) == NULL)
+				if ((gw_conf->got_site_link = strdup($2)) == NULL)
 				errx(1, "out of memory");
 		}
 		| GOT_LOGO STRING {
-      			if ((gw_conf->got_logo = strdup($2)) == NULL)
+				if ((gw_conf->got_logo = strdup($2)) == NULL)
 				errx(1, "out of memory");
 		}
 		| GOT_LOGO_URL STRING {
-      			if ((gw_conf->got_logo_url = strdup($2)) == NULL)
+				if ((gw_conf->got_logo_url = strdup($2)) == NULL)
 				errx(1, "out of memory");
 		}
 		| GOT_SHOW_SITE_OWNER boolean {
@@ -157,7 +157,7 @@ main		: GOT_REPOS_PATH STRING {
 			if ($2 > 0)
 				gw_conf->got_max_commits_display = $2;
 		}
-      		;
+		;
 
 %%
 
@@ -488,20 +488,20 @@ parse_conf(const char *filename, struct gotweb_conf *gconf)
 	static const struct got_error*	 error = NULL;
 
 	gw_conf = gconf;
-      	if ((gw_conf->got_repos_path = strdup(D_GOTPATH)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_www_path = strdup(D_GOTWWW)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_site_name = strdup(D_SITENAME)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_site_owner = strdup(D_SITEOWNER)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_site_link = strdup(D_SITELINK)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_logo = strdup(D_GOTLOGO)) == NULL)
-		errx(1, "out of memory");
-      	if ((gw_conf->got_logo_url = strdup(D_GOTURL)) == NULL)
-		errx(1, "out of memory");
+	if ((gw_conf->got_repos_path = strdup(D_GOTPATH)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_www_path = strdup(D_GOTWWW)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_site_name = strdup(D_SITENAME)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_site_owner = strdup(D_SITEOWNER)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_site_link = strdup(D_SITELINK)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_logo = strdup(D_GOTLOGO)) == NULL)
+	err(1, "strdup");
+	if ((gw_conf->got_logo_url = strdup(D_GOTURL)) == NULL)
+	err(1, "strdup");
 	gw_conf->got_show_site_owner = D_SHOWSOWNER;
 	gw_conf->got_show_repo_owner = D_SHOWROWNER;
 	gw_conf->got_show_repo_age = D_SHOWAGE;
diff --git a/lib/buf.c b/lib/buf.c
index 91c1809..3986b23 100644
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -41,13 +41,6 @@
 
 #define BUF_INCR	128
 
-struct buf {
-	/* buffer handle, buffer size, and data length */
-	u_char	*cb_buf;
-	size_t	 cb_size;
-	size_t	 cb_len;
-};
-
 #define SIZE_LEFT(b)	((b)->cb_size - (b)->cb_len)
 
 static const struct got_error *buf_grow(BUF *, size_t);
diff --git a/lib/buf.h b/lib/buf.h
index dcb2af9..9422c0f 100644
--- a/lib/buf.h
+++ b/lib/buf.h
@@ -42,6 +42,13 @@
 
 typedef struct buf BUF;
 
+struct buf {
+	/* buffer handle, buffer size, and data length */
+	u_char	*cb_buf;
+	size_t	 cb_size;
+	size_t	 cb_len;
+};
+
 const struct got_error *buf_alloc(BUF **, size_t);
 const struct got_error *buf_load(BUF **, const char *);
 void		 buf_free(BUF *);
diff --git a/libexec/Makefile.inc b/libexec/Makefile.inc
index 40fa9cc..a77207b 100644
--- a/libexec/Makefile.inc
+++ b/libexec/Makefile.inc
@@ -1,12 +1,13 @@
 .include "../Makefile.inc"
 
-.if ${MAKEWEB} == "Yes"
+.if "${MAKEWEB}" == "Yes"
 realinstall:
-	if [ ! -d ${LIBEXEC_DIR}/. ]; then \
-		${INSTALL} -d -o root -g daemon -m 755 ${LIBEXEC_DIR}; \
+	if [ ! -d ${CHROOT_DIR}${LIBEXECDIR}/. ]; then \
+		${INSTALL} -d -o root -g daemon -m 755 \
+		    ${CHROOT_DIR}${LIBEXECDIR}; \
 	fi
 	${INSTALL} ${INSTALL_COPY} -o root -g daemon -m 755 ${PROG} \
-	${LIBEXEC_DIR}/${PROG}
+	    ${CHROOT_DIR}${LIBEXECDIR}/${PROG}
 .else
 realinstall:
 	${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \