This file is indexed.

/var/spool/hylafax/bin/notify is in hylafax-server 3:6.0.6-5.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#! /bin/bash
#
# notify qfile why jobtime [nextTry]
#
# Return mail to the submitter of a job when notification is needed.
#
# This is a rewrite of the notify.sh.
# This version uses the "template" capabilityes to send the e-mails.
# FaxQueuer only calls notify if the job requested notification,
# So if we are called, we *will* send an email (barring any errors)
#
# etc/FaxNotify controls *what* we e-mail
# - TEMPLATE=subdir
# - RETURNFILETYPE=raw|PDF|PS|TIFF
#
# It send the e-mail to $mailaddr, which is the mailaddr of the job.
# The e-mail template used is selectec from:
#   - etc/templates/$TEMPLATE/notify-$WHY-page.txt (only for pager jobs)
#   - etc/templates/$TEMPLATE/notify-$WHY.txt
# If it is a pager job, and notify-$WHY-page.txt does *not* exist, it
# will use the notify-$WHY.txt template.
#
# It honours the RETURNFILETYPE variable that can be set by FaxNotify.
# If it is set, it will return *all* the submitted documents as attachments
# with the e-mail, converted to the RETURNFILETYPE.
# Multiple file types may be specified by separating them with
# whitespace; in that case a separate attachment for each filetype
# will be created.

. bin/common-functions

if [ $# != 3 ] && [ $# != 4 ]; then
    echo "Usage: $0 qfile why jobtime [nextTry]"
    hfExit 1
fi

test -f etc/setup.cache || {
    SPOOL=`pwd`
    cat<<EOF

FATAL ERROR: $SPOOL/etc/setup.cache is missing!

The file $SPOOL/etc/setup.cache is not present.  This
probably means the machine has not been setup using the faxsetup(8)
command.  Read the documentation on setting up HylaFAX before you
startup a server system.

EOF
    hfExit 1
}

# need to parse out the command line here.  some may be needed
# in the FaxNotify.
QFILE=$1
WHY=$2
JTIME=$3
NEXT=${4:-'??:??'}

# These settings may not be present in setup.cache if user upgraded and
# didn't re-run faxsetup; we set them before calling setup.cache for
# backward compatibility.
ENCODING=base64
TIFF2PDF=bin/tiff2pdf
TTYCMD=tty

. etc/setup.cache

INFO=$SBIN/faxinfo
TIFFINFO=tiffinfo
FAX2PS=$TIFFBIN/fax2ps
TIFF2PS=tiff2ps
PS2PDF=ps2pdf
PDF2PS=pdf2ps
PS2FAX=bin/ps2fax
PDF2FAX=bin/pdf2fax
TOADDR=FaxMaster
FROMADDR=FaxMaster
NOTIFY_FAXMASTER=never
RETURNFILETYPE=
MIMEBOUNDARY="NextPart$$" RETURNTECHINFO=yes 
# Redirect errors to a tty, if possible, rather than
# dev-nulling them or allowing them to creep into
# the mail.
#
if $TTYCMD >/dev/null 2>&1; then
    ERRORSTO=`$TTYCMD`
else
    ERRORSTO=/dev/null
fi

##########
##  MAIN
##########

SetupPrivateTmp

# we parse the q file fisrt in case any of the varialbe setting 
# operations may want to know about the details of the fax
parseQfile  

if [ "$doneop" = "default" ] ; then
    doneop="remove"
fi
if [ "$jobtype" = "pager" ] ; then
    number=$pagernum
fi
if [ -n "$receiver" ]; then
    DESTINATION="$receiver ($number)"
else
    DESTINATION="$number"
fi
if [ -n "$jobtag" ]; then
    JOBINFO="$jobtag ($jobid)"
else
    JOBINFO="$jobid"
fi

COMMID=$commid
SENDTO=""
export COMMID SENDTO FROMADDR TOADDR DESTINATION WHY JTIME NEXT JOBINFO

# Faxmaster notify is just a simple notification, never with docs
do_faxmaster()
{
    template="etc/templates/$TEMPLATE/notify-faxmaster.txt"
    SENDTO="$TOADDR"

    if [ -f etc/templates/$TEMPLATE/hook.sh ]
    then
        # Any hooks that the templates need
        . etc/templates/$TEMPLATE/hook.sh
    fi

    #We don't need eval here, because not attachment args here
    CreateMailMessage "$template" 2>$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi "$SENDTO"
}

# This does the grunt work of building the notify email
do_notify()
{

    if [ -f etc/templates/$TEMPLATE/hook.sh ]
    then
        # Any hooks that the templates need
        . etc/templates/$TEMPLATE/hook.sh
    fi


    if [ -n "$RETURNFILETYPE" ]; then
        for ft in $RETURNFILETYPE
        do
            ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgs $ft`
        done
    fi

    template="etc/templates/$TEMPLATE/notify-$WHY.txt"
    if [ "$jobtype" != "facsimile" ] && [ -f etc/templates/$TEMPLATE/notify-$WHY-page.txt ]; then
            template="etc/templates/$TEMPLATE/notify-$WHY-page.txt"
    fi


    eval CreateMailMessage "$template" $ATTACH_ARGS \
            2>$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi "$SENDTO"
}


#
# Apply customizations.  All customizable variables should
# be set to their non-customized defaults prior to this.
#
if [ -f etc/FaxNotify ]; then
    # source notify preferences
    . etc/FaxNotify
fi


## We process the NOTIFY_FAXMASTER first, because we want
## this to go without the attachemnts, if they are used
## Faxmaster goes to $TOADDR, but templates always use SENDTO
SENDTO="$TOADDR"
case "$NOTIFY_FAXMASTER:$WHY" in
    "always:"*)                     do_faxmaster;;
    "yes:"*)                        do_faxmaster;;

    "errors:success")               ;;              # Not errors
    "errors:blocked")               ;;              # Not errors
    "errors:"*)                     do_faxmaster;;  # errors

    *)                              ;;              # Do nothing;
esac

# We use SENDTO in the templates, but $mailaddr is the job
# param.  We set this *after* FaxNotify is sourced, because
# some admins seem to play with mailaddr expecting it to change
# the destination of the nofify email
SENDTO="$mailaddr"
export SENDTO

case "$WHY:$notify" in
    *":always")                     do_notify;;     # They've asked for it

    "requeued:when done+requeued")  do_notify;;     # Requeued
    "requeued:when requeued")       do_notify;;     # Requeued
    "requeued:when done")           ;;              # Do nothing;
    "requeued:none")                ;;              # Do nothing;

    "blocked:"*)                    ;;              # Blocked

    "done:when done+requeued")      do_notify;;     # Done
    "done:when requeued")           ;;              # Do nothing
    "done:when done")               do_notify;;     # Done
    "done:none")                    ;;              # Do nothing

    # Anything else is a "failure", which always runs notification
    *)                              do_notify;;
esac


CleanupPrivateTmp