File: node36.html

package info (click to toggle)
rutebook 1.0-1
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 9,476 kB
  • ctags: 1,112
  • sloc: makefile: 47
file content (463 lines) | stat: -rw-r--r-- 18,904 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>33. Sending Faxes</TITLE>
<META NAME="description" CONTENT="33. Sending Faxes">
<META NAME="keywords" CONTENT="rute">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="rute.css">

<LINK REL="next" HREF="node37.html">
<LINK REL="previous" HREF="node35.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node37.html">
</HEAD>

<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>&nbsp;
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright&nbsp;&#169;&nbsp;2002&nbsp;Paul Sheer. <A HREF="copying.html"><FONT COLOR=white>Click here for copying permissions.</FONT></A>
</FONT>
</TD><TD align=right bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>&nbsp;
</FONT>
</TD></TR>
<TR><TD colspan=2 align=left bgcolor="#ECEBF4">
<IMG SRC="va-btn-small-light-60.png">
</TD><TD align=right bgcolor="#ECEBF4">
<IMG SRC="sflogo2-steel-60.png">
</TD></TR>
</TABLE><BR>

<!--Navigation Panel-->
<A NAME="tex2html2456"
  HREF="node37.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2452"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2446"
  HREF="node35.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2454"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html2457"
  HREF="node37.html">34. uucp and uux</A>
<B> Up:</B> <A NAME="tex2html2453"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2447"
  HREF="node35.html">32. init, ? getty,</A>
 &nbsp <B>  <A NAME="tex2html2455"
  HREF="node1.html">Contents</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html2458"
  HREF="#SECTION003610000000000000000">33.1 Fax Through Printing</A>
<LI><A NAME="tex2html2459"
  HREF="#SECTION003620000000000000000">33.2 Setgid Wrapper Binary</A>
</UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION003600000000000000000">
33. Sending Faxes</A>
</H1>

<P>
<A NAME="chap:sendingfaxes"></A>
<P>
This chapter discusses the <TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> program, with reference to the
specific example of setting up an artificial printer that will automatically use a
modem to send its print jobs to remote fax machines.

<P>

<H1><A NAME="SECTION003610000000000000000">
33.1 Fax Through Printing</A>
</H1>

<P>
<I>Continuing from Section <A HREF="node24.html#sec:printtononprinter">21.10</A>...</I>

<P>
You should go now and read the <TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> section of the <TT>
<FONT COLOR="#0000ff">info</FONT></TT> page
for <TT>
<FONT COLOR="#0000ff">mgetty</FONT></TT>. The <TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> command is just one program that
sends faxes through the modem. Like <TT>
<FONT COLOR="#0000ff">mgetty</FONT></TT>, it reads a config file
in <TT>
<FONT COLOR="#0000ff">/etc/mgetty+sendfax/</FONT></TT>. This
config file is just <TT>
<FONT COLOR="#0000ff">sendfax.config</FONT></TT>
and can contain as little as

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>verbose&nbsp;y</code><br>
<code>debug&nbsp;5</code><br>
<code>fax-devices&nbsp;ttyS0</code><br>
<code>fax-id&nbsp;27&nbsp;21&nbsp;7654321</code><br>
<code>max-tries&nbsp;3</code><br>
<code>max-tries-continue&nbsp;y</code><br>
</FONT></TD></TR></TABLE><P>

<P>
Below, <TT>
<FONT COLOR="#0000ff">fax_filter.sh</FONT></TT>
is a script that sends the print job
through the fax machine after requesting the telephone number through
<TT>
<FONT COLOR="#0000ff">gdialog</FONT></TT>. <FONT COLOR="#ffa500">[<TT>
<FONT COLOR="#0000ff">gdialog</FONT></TT> is part of the <TT>
<FONT COLOR="#0000ff">gnome-utils</FONT></TT>
package.]</FONT> An appropriate <TT>
<FONT COLOR="#0000ff">/etc/printcap</FONT></TT> entry is:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>fax:\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:sd=/var/spool/lpd/fax:\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:mx#0:\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:sh:\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:lp=/dev/null:\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:if=/var/spool/lpd/fax/fax_filter.sh:</code><br>
</FONT></TD></TR></TABLE><P>

<P>
The file <TT>
<FONT COLOR="#0000ff">fax_filter.sh</FONT></TT> itself could contain a script like
this <FONT COLOR="#ffa500">[Remember to rotate the
<TT>
<FONT COLOR="#0000ff">/var/log/fax</FONT></TT> log file, see page
<A HREF="node24.html#sec:logrotation"><IMG  ALIGN="BOTTOM" BORDER="1" ALT="[*]" SRC="crossref.png"></A>.]</FONT> for a modem on
<TT>
<FONT COLOR="#0000ff">/dev/ttyS0</FONT></TT>:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>10</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>15</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>20</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>25</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>30</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>35</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>40</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>45</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>50</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>55</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>#!/bin/sh</code><br>
<code>&nbsp;</code><br>
<code>exec&nbsp;1&#062;&#062;/var/log/fax</code><br>
<code>exec&nbsp;2&#062;&#062;/var/log/fax</code><br>
<code>&nbsp;</code><br>
<code>echo</code><br>
<code>echo</code><br>
<code>echo&nbsp;$@</code><br>
<code>&nbsp;</code><br>
<code>echo&nbsp;"Starting&nbsp;fax&nbsp;`date`:&nbsp;I&nbsp;am&nbsp;`id`"</code><br>
<code>&nbsp;</code><br>
<code>export&nbsp;DISPLAY=localhost:0.0</code><br>
<code>export&nbsp;HOME=/home/lp</code><br>
<code>&nbsp;</code><br>
<code>function&nbsp;error()</code><br>
<code>{</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;gdialog&nbsp;--title&nbsp;"Send&nbsp;Fax"&nbsp;--msgbox&nbsp;"$1"&nbsp;10&nbsp;75&nbsp;||&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;'Huh?&nbsp;no&nbsp;gdialog&nbsp;on&nbsp;this&nbsp;machine'</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;cd&nbsp;/</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;rm&nbsp;-Rf&nbsp;/tmp/$$fax&nbsp;||&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gdialog&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--title&nbsp;"Send&nbsp;Fax"&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--msgbox&nbsp;"rm&nbsp;-Rf&nbsp;/tmp/$$fax&nbsp;failed"&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;75</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;1</code><br>
<code>}</code><br>
<code>&nbsp;</code><br>
<code>mkdir&nbsp;/tmp/$$fax&nbsp;||&nbsp;error&nbsp;"mkdir&nbsp;/tmp/$$fax&nbsp;failed"</code><br>
<code>cd&nbsp;/tmp/$$fax&nbsp;||&nbsp;error&nbsp;"cd&nbsp;/tmp/$$fax&nbsp;failed"</code><br>
<code>&nbsp;</code><br>
<code>cat&nbsp;&#062;&nbsp;fax.ps</code><br>
<code>&nbsp;</code><br>
<code>if&nbsp;/usr/bin/gdialog&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--title&nbsp;"Send&nbsp;Fax"&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--inputbox&nbsp;"Enter&nbsp;the&nbsp;phone&nbsp;number&nbsp;to&nbsp;fax:"&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10&nbsp;75&nbsp;""&nbsp;2&#062;TEL&nbsp;&#059;&nbsp;then</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;:</code><br>
<code>else</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;"gdialog&nbsp;failed&nbsp;`&#060;&nbsp;TEL`"</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;rm&nbsp;-Rf&nbsp;/tmp/$$fax</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;0</code><br>
<code>fi</code><br>
<code>&nbsp;</code><br>
<code>TEL=`&#060;&nbsp;TEL`</code><br>
<code>test&nbsp;-z&nbsp;"$TEL"&nbsp;&#038;&#038;&nbsp;error&nbsp;'no&nbsp;telephone&nbsp;number&nbsp;given'</code><br>
<code>&nbsp;</code><br>
<code>cat&nbsp;fax.ps&nbsp;|&nbsp;gs&nbsp;-r204x98&nbsp;-sOutputFile=-&nbsp;-sDEVICE=faxg3&nbsp;-dBATCH&nbsp;-q&nbsp;-&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;1&#062;fax.ps.g3&nbsp;||&nbsp;error&nbsp;'gs&nbsp;failed'</code><br>
<code>&nbsp;</code><br>
<code>ls&nbsp;-al&nbsp;/var/lock/</code><br>
<code>/usr/sbin/sendfax&nbsp;-x&nbsp;5&nbsp;-n&nbsp;-l&nbsp;ttyS0&nbsp;$TEL&nbsp;fax.ps.g3&nbsp;||&nbsp;\</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;error&nbsp;"sendfax&nbsp;failed"</code><br>
<code>&nbsp;</code><br>
<code>rm&nbsp;-Rf&nbsp;/tmp/$$fax</code><br>
<code>&nbsp;</code><br>
<code>exit&nbsp;0</code><br>
</FONT></TD></TR></TABLE><P>

<P>

<H1><A NAME="SECTION003620000000000000000">
33.2 Setgid Wrapper Binary</A>
</H1>

<P>
<A NAME="sec:faxsetuidbin"></A>
<P>
The above script is not enough however. Above, <TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> requires access to the
<TT>
<FONT COLOR="#0000ff">/dev/ttyS0</FONT></TT> device as well as the
<TT>
<FONT COLOR="#0000ff">/var/lock/</FONT></TT> directory (to
create a modem lock file--see Section <A HREF="node37.html#sec:ttylockfile">34.4</A>). It cannot do
that as the <TT>
<FONT COLOR="#0000ff">lp</FONT></TT> user (under which the above filter runs).
On RedHat, the command <TT>
<FONT COLOR="#0000ff">ls -ald /var/lock /dev/ttyS0</FONT></TT> reveals that only
<TT>
<FONT COLOR="#0000ff">uucp</FONT></TT> is allowed to access modems.
We can get around this restriction
by creating a setgid
(see Chapter <A HREF="node17.html#chap:permmodtimes">14</A>) binary that runs as the
<TT>
<FONT COLOR="#0000ff">uucp</FONT></TT> user. Do this by compiling the <B>C</B> program,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red size="-1">
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>10</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>15</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>20</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>25</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-2"><code>30</code></font><code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue size="-1">
<code>#include&nbsp;&#060;stdlib.h&#062;</code><br>
<code>#include&nbsp;&#060;string.h&#062;</code><br>
<code>#include&nbsp;&#060;stdio.h&#062;</code><br>
<code>#include&nbsp;&#060;unistd.h&#062;</code><br>
<code>&nbsp;</code><br>
<code>int&nbsp;main&nbsp;(int&nbsp;argc,&nbsp;char&nbsp;**argv)</code><br>
<code>{</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;**a&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;i&#059;</code><br>
<code>&nbsp;</code><br>
<code>/*&nbsp;set&nbsp;the&nbsp;real&nbsp;group&nbsp;ID&nbsp;to&nbsp;that&nbsp;of&nbsp;the&nbsp;effective&nbsp;group&nbsp;ID&nbsp;*/</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(setgid&nbsp;(getegid&nbsp;()))&nbsp;{</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perror&nbsp;("sendfax_wrapper:&nbsp;setgid&nbsp;failed")&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;(1)&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;}</code><br>
<code>&nbsp;</code><br>
<code>/*&nbsp;copy&nbsp;all&nbsp;arguments&nbsp;*/</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;(char&nbsp;**)&nbsp;malloc&nbsp;((argc&nbsp;+&nbsp;1)&nbsp;*&nbsp;sizeof&nbsp;(char&nbsp;*))&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(i&nbsp;=&nbsp;1&#059;&nbsp;i&nbsp;&#060;&nbsp;argc&#059;&nbsp;i++)</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[i]&nbsp;=&nbsp;(char&nbsp;*)&nbsp;strdup&nbsp;(argv[i])&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;a[argc]&nbsp;=&nbsp;NULL&#059;</code><br>
<code>&nbsp;</code><br>
<code>/*&nbsp;execute&nbsp;sendfax&nbsp;*/</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;a[0]&nbsp;=&nbsp;"/usr/sbin/sendfax"&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;execvp&nbsp;(a[0],&nbsp;a)&#059;</code><br>
<code>&nbsp;</code><br>
<code>/*&nbsp;exit&nbsp;on&nbsp;failure&nbsp;*/</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;perror&nbsp;("sendfax_wrapper:&nbsp;failed&nbsp;to&nbsp;exececute&nbsp;/usr/sbin/sendfax")&#059;</code><br>
<code>&nbsp;&nbsp;&nbsp;&nbsp;exit&nbsp;(1)&#059;</code><br>
<code>}</code><br>
</FONT></TD></TR></TABLE><P>
using the commands,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>gcc&nbsp;sendfax_wrapper.c&nbsp;-o&nbsp;/usr/sbin/sendfax_wrapper&nbsp;-Wall</code><br>
<code>chown&nbsp;lp:uucp&nbsp;/usr/sbin/sendfax_wrapper</code><br>
<code>chmod&nbsp;g+s,o-rwx&nbsp;/usr/sbin/sendfax_wrapper</code><br>
</FONT></TD></TR></TABLE><P>
Then, replace
<TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> with <TT>
<FONT COLOR="#0000ff">sendfax_wrapper</FONT></TT> in the filter script. You can
see that <TT>
<FONT COLOR="#0000ff">sendfax_wrapper</FONT></TT> just executes <TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> after changing
the group ID to the <I>effective group ID</I> (GID) as obtained from the <TT>
<FONT COLOR="#0000ff">getegid</FONT></TT>
function on line 12. The effective group ID is <TT>
<FONT COLOR="#0000ff">uucp</FONT></TT> because of the
setgid group bit (i.e., <TT>
<FONT COLOR="#0000ff">g+s</FONT></TT>) in the
<TT>
<FONT COLOR="#0000ff">chmod</FONT></TT> command, and hence
<TT>
<FONT COLOR="#0000ff">sendfax</FONT></TT> runs under the <TT>
<FONT COLOR="#0000ff">uucp</FONT></TT> group with full access to the modem
device.

<P>
On your own system it may be cleaner to try implement this without a
wrapper. Debian, for example, has a <TT>
<FONT COLOR="#0000ff">dialout</FONT></TT> group for the
purposes of accessing modems. Also be aware that some distributions may
not use the <TT>
<FONT COLOR="#0000ff">uucp</FONT></TT> user in the way RedHat does and you may have to
create an alternative user especially for this task.

<P>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html2456"
  HREF="node37.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2452"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2446"
  HREF="node35.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2454"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html2457"
  HREF="node37.html">34. uucp and uux</A>
<B> Up:</B> <A NAME="tex2html2453"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2447"
  HREF="node35.html">32. init, ? getty,</A>
 &nbsp <B>  <A NAME="tex2html2455"
  HREF="node1.html">Contents</A></B> 
<!--End of Navigation Panel-->

</BODY>
</HTML>