Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
ffaf59d9
...
ffaf59d9d2bfdd1282d477e4b27791294bc92f81
authored
2001-06-26 14:04:07 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Call util_save_outgoing() to preserve the message.
Set umask 077 before calling mkstemp().
1 parent
46aac409
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
9 deletions
mail/send.c
mail/send.c
View file @
ffaf59d
...
...
@@ -57,14 +57,20 @@ mail_send (int argc, char **argv)
else
subj
=
(
util_find_env
(
"subject"
))
->
value
;
return
mail_send0
(
to
,
cc
,
bcc
,
subj
);
return
mail_send0
(
to
,
cc
,
bcc
,
subj
,
isupper
(
argv
[
0
][
0
])
);
}
/* Shared between mail_send() and mail_reply();
NOTE: arguments should be allocated dynamically. They will be freed
/* mail_send0(): shared between mail_send() and mail_reply();
If the variable "record" is set, the outgoing message is
saved after being sent. If "save_to" argument is non-zero,
the name of the save file is derived from "to" argument. Otherwise,
it is taken from the value of "record" variable.
NOTE: arguments must be allocated dynamically. They will be freed
before exit */
int
mail_send0
(
char
*
to
,
char
*
cc
,
char
*
bcc
,
char
*
subj
)
mail_send0
(
char
*
to
,
char
*
cc
,
char
*
bcc
,
char
*
subj
,
int
save_to
)
{
char
*
buf
=
NULL
;
size_t
n
=
0
;
...
...
@@ -73,17 +79,22 @@ mail_send0 (char *to, char *cc, char *bcc, char *subj)
char
*
filename
;
FILE
*
file
;
const
char
*
tmpdir
;
char
*
savefile
=
NULL
;
/* We have to be extra careful about opening temporary files, since we
may be running with extra privilege i.e setgid(). */
tmpdir
=
(
getenv
(
"TMPDIR"
))
?
getenv
(
"TMPDIR"
)
:
"/tmp"
;
filename
=
alloca
(
strlen
(
tmpdir
)
+
/*'/'*/
1
+
/* "muXXXXXX" */
8
+
1
);
sprintf
(
filename
,
"%s/muXXXXXX"
,
tmpdir
);
#ifdef HAVE_MKSTEMP
fd
=
mkstemp
(
filename
);
{
int
save_mask
=
umask
(
077
);
fd
=
mkstemp
(
filename
);
umask
(
save_mask
);
}
#else
if
(
mktemp
(
filename
))
fd
=
open
(
filename
,
O_CREAT
|
O_EXCL
|
O_
WRONLY
,
0600
);
fd
=
open
(
filename
,
O_CREAT
|
O_EXCL
|
O_
RDWR
,
0600
);
else
fd
=
-
1
;
#endif
...
...
@@ -94,7 +105,7 @@ mail_send0 (char *to, char *cc, char *bcc, char *subj)
return
1
;
}
file
=
fdopen
(
fd
,
"w"
);
file
=
fdopen
(
fd
,
"w
+
"
);
while
(
getline
(
&
buf
,
&
n
,
stdin
)
>=
0
&&
!
done
)
{
...
...
@@ -278,9 +289,25 @@ mail_send0 (char *to, char *cc, char *bcc, char *subj)
free
(
buf
);
buf
=
NULL
;
}
fclose
(
file
);
}
fclose
(
file
);
/* Save outgoing message */
if
(
save_to
)
{
savefile
=
strdup
(
to
);
if
(
savefile
)
{
char
*
p
=
strchr
(
savefile
,
'@'
);
if
(
p
)
*
p
=
0
;
}
}
util_save_outgoing
(
msg
,
savefile
);
if
(
savefile
)
free
(
savefile
);
/* Send the message. */
mailer_send_message
(
mailer
,
msg
);
message_destroy
(
&
msg
,
NULL
);
...
...
Please
register
or
sign in
to post a comment