Skip to content

Commit

Permalink
Partial revert of pathnames
Browse files Browse the repository at this point in the history
Parts of the code require relative pathnames for validating
paths.
  • Loading branch information
michel-stam committed Jul 4, 2024
1 parent a1b9caf commit e5bf250
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 62 deletions.
10 changes: 5 additions & 5 deletions coreutils/condmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,28 @@ int condmv_main(int argc, char *argv[])
from= argv[optind];
to= argv[optind+1];

rebased_from= rebased_validated_filename(ATLAS_DATA,
rebased_from= rebased_validated_filename(ATLAS_SPOOLDIR,
from, SAFE_PREFIX_FROM1_REL);
if (rebased_from == NULL)
{
rebased_from= rebased_validated_filename(ATLAS_DATA,
rebased_from= rebased_validated_filename(ATLAS_SPOOLDIR,
from, SAFE_PREFIX_FROM2_REL);
}
if (rebased_from == NULL)
{
fprintf(stderr, "insecure from file '%s'\n", from);
goto err;
}
rebased_to= rebased_validated_filename(ATLAS_DATA,
rebased_to= rebased_validated_filename(ATLAS_SPOOLDIR,
to, SAFE_PREFIX_TO1_REL);
if (rebased_to == NULL)
{
rebased_to= rebased_validated_filename(ATLAS_DATA,
rebased_to= rebased_validated_filename(ATLAS_SPOOLDIR,
to, SAFE_PREFIX_TO2_REL);
}
if (rebased_to == NULL)
{
rebased_to= rebased_validated_filename(ATLAS_DATA,
rebased_to= rebased_validated_filename(ATLAS_SPOOLDIR,
to, SAFE_PREFIX_FROM1_REL);
}
if (rebased_to == NULL)
Expand Down
4 changes: 2 additions & 2 deletions eperd/condmv.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ static void *condmv_init(int argc, char *argv[],
from= argv[optind];
to= argv[optind+1];

rebased_from= rebased_validated_filename(ATLAS_DATA, from, SAFE_PREFIX_FROM_REL);
rebased_from= rebased_validated_filename(ATLAS_SPOOLDIR, from, SAFE_PREFIX_FROM_REL);
if (!rebased_from)
{
fprintf(stderr, "insecure from file '%s'\n", from);
return NULL;
}
rebased_to= rebased_validated_filename(ATLAS_DATA, to, SAFE_PREFIX_TO_REL);
rebased_to= rebased_validated_filename(ATLAS_SPOOLDIR, to, SAFE_PREFIX_TO_REL);
if (!rebased_to)
{
free(rebased_from); rebased_from= NULL;
Expand Down
44 changes: 22 additions & 22 deletions eperd/eooqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#include "atlas_path.h"

#define SUFFIX ".curr"
#define OOQD_NEW_PREFIX_REL "new/ooq"
#define OOQD_OUT_PREFIX_REL "out/ooq"
#define ATLAS_SESSION_FILE_REL "con_session_id.txt"
#define REPORT_HEADER_REL "p_to_c_report_header"
#define SESSION_ID_REL "con_session_id.txt"
#define OOQ_SENT_REL "new/ooq_sent.vol"
#define OOQD_NEW_PREFIX_REL "data/new/ooq"
#define OOQD_OUT_PREFIX_REL "data/out/ooq"
#define ATLAS_SESSION_FILE_REL "status/con_session_id.txt"
#define REPORT_HEADER_REL "status/p_to_c_report_header"
#define SESSION_ID_REL "status/con_session_id.txt"
#define OOQ_SENT_REL "data/new/ooq_sent.vol"

#define ATLAS_NARGS 64 /* Max arguments to a built-in command */
#define ATLAS_ARGSIZE 512 /* Max size of the command line */
Expand Down Expand Up @@ -214,7 +214,7 @@ int eooqd_main(int argc, char *argv[])

snprintf(output_filename, sizeof(output_filename),
"%s/" OOQD_OUT_PREFIX_REL "%s/ooq.out",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);

signal(SIGQUIT, SIG_DFL);
limit.rlim_cur= RLIM_INFINITY;
Expand Down Expand Up @@ -408,7 +408,7 @@ static int add_line(void)
p= &cmdline[len];
while (*p != '\0' && *p == ' ')
p++;
validated_fn= rebased_validated_filename(ATLAS_DATA,
validated_fn= rebased_validated_filename(ATLAS_SPOOLDIR,
p, SAFE_PREFIX_REL);
if (validated_fn == NULL)
{
Expand Down Expand Up @@ -535,7 +535,7 @@ static int add_line(void)
argv[argc++]= "-O";
snprintf(filename, sizeof(filename),
"%s/" OOQD_NEW_PREFIX_REL "%s.%d",
ATLAS_DATA, queue_id, slot);
ATLAS_SPOOLDIR, queue_id, slot);
argv[argc++]= filename;

argv[argc]= NULL;
Expand All @@ -561,7 +561,7 @@ static int add_line(void)
{
snprintf(filename, sizeof(filename),
"%s/" OOQD_NEW_PREFIX_REL "%s",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);
fn= fopen(filename, "a");
if (!fn)
{
Expand Down Expand Up @@ -591,7 +591,7 @@ static int add_line(void)

snprintf(filename2, sizeof(filename2),
"%s/" OOQD_OUT_PREFIX_REL "%s/ooq",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);
if (stat(filename2, &sb) == -1 &&
stat(filename, &sb) == 0)
{
Expand Down Expand Up @@ -638,10 +638,10 @@ static void cmddone(void *cmdstate, int error UNUSED_PARAM)

snprintf(from_filename, sizeof(from_filename),
"%s/" OOQD_NEW_PREFIX_REL "%s.%d",
ATLAS_DATA, queue_id, i);
ATLAS_SPOOLDIR, queue_id, i);

snprintf(to_filename, sizeof(to_filename),
"%s/%s/%s/%d", ATLAS_DATA,
"%s/%s/%s/%d", ATLAS_SPOOLDIR,
OOQD_OUT_PREFIX_REL, queue_id, i);

if (stat(to_filename, &sb) == 0)
Expand Down Expand Up @@ -737,10 +737,10 @@ static void post_results(int force_post)

snprintf(from_filename, sizeof(from_filename),
"%s/" OOQD_NEW_PREFIX_REL "%s",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);
snprintf(to_filename, sizeof(to_filename),
"%s/" OOQD_OUT_PREFIX_REL "%s/ooq",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);
if (stat(to_filename, &sb) == 0)
{
/* There is more to post */
Expand All @@ -759,10 +759,10 @@ static void post_results(int force_post)
{
snprintf(from_filename, sizeof(from_filename),
"%s/" OOQD_NEW_PREFIX_REL "%s.%d",
ATLAS_DATA, queue_id, i);
ATLAS_SPOOLDIR, queue_id, i);
snprintf(to_filename, sizeof(to_filename),
"%s/" OOQD_OUT_PREFIX_REL "%s/%d",
ATLAS_DATA, queue_id, i);
ATLAS_SPOOLDIR, queue_id, i);
if (stat(to_filename, &sb) == 0)
{
/* There is more to post */
Expand Down Expand Up @@ -797,11 +797,11 @@ static void post_results(int force_post)
probe_id, session_id);
snprintf(from_filename, sizeof(from_filename),
"%s/" OOQD_OUT_PREFIX_REL "%s",
ATLAS_DATA, queue_id);
ATLAS_SPOOLDIR, queue_id);

asprintf(&fn_header, "%s/%s", ATLAS_STATUS, REPORT_HEADER_REL);
asprintf(&fn_session_id, "%s/%s", ATLAS_STATUS, SESSION_ID_REL);
asprintf(&fn_ooq_sent, "%s/%s", ATLAS_DATA, OOQ_SENT_REL);
asprintf(&fn_header, "%s/%s", ATLAS_RUNDIR, REPORT_HEADER_REL);
asprintf(&fn_session_id, "%s/%s", ATLAS_RUNDIR, SESSION_ID_REL);
asprintf(&fn_ooq_sent, "%s/%s", ATLAS_SPOOLDIR, OOQ_SENT_REL);
i= 0;
argv[i++]= "httppost";
argv[i++]= "-A";
Expand Down Expand Up @@ -837,7 +837,7 @@ static const char *get_session_id(void)
char *cp, *fn;
FILE *file;

asprintf(&fn, "%s/%s", ATLAS_STATUS, ATLAS_SESSION_FILE_REL);
asprintf(&fn, "%s/%s", ATLAS_RUNDIR, ATLAS_SESSION_FILE_REL);
file= fopen(fn, "r");
free(fn); fn= NULL;
if (file == NULL)
Expand Down
2 changes: 1 addition & 1 deletion eperd/eperd.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int eperd_main(int argc UNUSED_PARAM, char **argv)

if (out_filename)
{
validated_fn= rebased_validated_filename(ATLAS_DATA,
validated_fn= rebased_validated_filename(ATLAS_SPOOLDIR,
out_filename, SAFE_PREFIX_REL);
if (validated_fn == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion eperd/evtdig.c
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ static bool argProcess (int argc, char *argv[], struct query_state *qry )

if (qry->out_filename)
{
validated_fn= rebased_validated_filename(ATLAS_DATA,
validated_fn= rebased_validated_filename(ATLAS_SPOOLDIR,
qry->out_filename, SAFE_PREFIX_REL);
if (validated_fn == NULL)
{
Expand Down
8 changes: 4 additions & 4 deletions eperd/httpget.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[],

if (output_file)
{
validated_output_file= rebased_validated_filename(ATLAS_DATA,
validated_output_file= rebased_validated_filename(ATLAS_SPOOLDIR,
output_file, SAFE_PREFIX_OUT_REL);
if (validated_output_file == NULL)
{
Expand Down Expand Up @@ -639,7 +639,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[],

if (post_header)
{
validated_post_header= rebased_validated_filename(ATLAS_DATA,
validated_post_header= rebased_validated_filename(ATLAS_SPOOLDIR,
post_header, SAFE_PREFIX_IN_REL);
if (validated_post_header == NULL)
{
Expand All @@ -649,7 +649,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[],
}
if (post_file)
{
validated_post_file= rebased_validated_filename(ATLAS_DATA,
validated_post_file= rebased_validated_filename(ATLAS_SPOOLDIR,
post_file, SAFE_PREFIX_IN_REL);
if (validated_post_file == NULL)
{
Expand All @@ -659,7 +659,7 @@ static void *httpget_init(int __attribute((unused)) argc, char *argv[],
}
if (post_footer)
{
validated_post_footer= rebased_validated_filename(ATLAS_DATA,
validated_post_footer= rebased_validated_filename(ATLAS_SPOOLDIR,
post_footer, SAFE_PREFIX_IN_REL);
if (validated_post_footer == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion eperd/ntp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ static void *ntp_init(int __attribute((unused)) argc, char *argv[],

if (out_filename)
{
validated_out_filename= rebased_validated_filename(ATLAS_DATA,
validated_out_filename= rebased_validated_filename(ATLAS_SPOOLDIR,
out_filename, SAFE_PREFIX_REL);
if (!validated_out_filename)
{
Expand Down
2 changes: 1 addition & 1 deletion eperd/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ static void *ping_init(int __attribute((unused)) argc, char *argv[],

if (out_filename)
{
validated_out_filename= rebased_validated_filename(ATLAS_DATA,
validated_out_filename= rebased_validated_filename(ATLAS_SPOOLDIR,
out_filename, SAFE_PREFIX_REL);
if (!validated_out_filename)
{
Expand Down
2 changes: 1 addition & 1 deletion eperd/sslgetcert.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ static void *sslgetcert_init(int __attribute((unused)) argc, char *argv[],

if (output_file)
{
validated_output_file= rebased_validated_filename(ATLAS_DATA,
validated_output_file= rebased_validated_filename(ATLAS_SPOOLDIR,
output_file, SAFE_PREFIX_OUT_REL);
if (!validated_output_file)
{
Expand Down
2 changes: 1 addition & 1 deletion eperd/traceroute.c
Original file line number Diff line number Diff line change
Expand Up @@ -4310,7 +4310,7 @@ static void *traceroute_init(int __attribute((unused)) argc, char *argv[],

if (out_filename)
{
validated_out_filename= rebased_validated_filename(ATLAS_DATA,
validated_out_filename= rebased_validated_filename(ATLAS_SPOOLDIR,
out_filename, SAFE_PREFIX_REL);
if (!validated_out_filename)
{
Expand Down
8 changes: 4 additions & 4 deletions include/libbb.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ char *is_suffixed_with(const char *string, const char *key) FAST_FUNC;
#define ATLAS_HOME "/home/atlas"
#define ATLAS_CRONS_REL "crons"
#define ATLAS_STATUS_REL "status"
#define ATLAS_DATA_OUT_REL "out"
#define ATLAS_DATA_OOQ_OUT_REL "ooq.out"
#define ATLAS_DATA_NEW_REL "new"
#define ATLAS_DATA_STORAGE_REL "storage"
#define ATLAS_DATA_OUT_REL "data/out"
#define ATLAS_DATA_OOQ_OUT_REL "data/ooq.out"
#define ATLAS_DATA_NEW_REL "data/new"
#define ATLAS_DATA_STORAGE_REL "data/storage"
#define ATLAS_TIMESYNC_FILE_REL ATLAS_DATA_NEW_REL "/timesync.vol"
#define ATLAS_FUZZING_REL "data"

Expand Down
2 changes: 1 addition & 1 deletion libbb/atlas_timesync.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int get_timesync(void)
if (atlas_tests())
return 123;

asprintf(&fn, "%s/%s", ATLAS_DATA, ATLAS_TIMESYNC_FILE_REL);
asprintf(&fn, "%s/%s", ATLAS_SPOOLDIR, ATLAS_TIMESYNC_FILE_REL);
fh= fopen(fn, "r");
free(fn); fn= NULL;
if (!fh)
Expand Down
2 changes: 1 addition & 1 deletion miscutils/perd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ static int atlas_run(char *cmdline)
{
/* Redirect I/O */
crondlog(LVL7 "sending output to '%s'", outfile);
validated_fn= rebased_validated_filename(ATLAS_DATA,
validated_fn= rebased_validated_filename(ATLAS_SPOOLDIR,
outfile, SAFE_PREFIX_REL);
if (!validated_fn)
{
Expand Down
Loading

0 comments on commit e5bf250

Please sign in to comment.