systemd-openbsd/init/systemd-dir.c
Reyk Floeter ef95987cfd Rename syslib_log to systemd_journal and log as JSON to improve readability.
Add the optional -DBINARYLOGS flag to encode the JSON logs as Base64.
This allows to log binary data as well but it is turned off for
backwards-compatibility.

Requested by https://github.com/reyk/systemd-openbsd/issues/3
2019-06-18 15:02:15 +02:00

45 lines
1.4 KiB
C

/*
* This file is part of the satirical systemd-openbsd.
*
* DON'T USE THIS IN PRODUCTION! DON'T USE IT ON YOUR MACHINE!
* DON'T TAKE IT SERIOUS! IT MIGHT DELETE YOUR FILES.
*
* Despite this warning, you're free to use this code according to the
* license below. Parts of it might be useful in other places after all.
*/
/*
* Copyright (c) 2019 Reyk Floeter <contact@reykfloeter.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <limits.h>
#include "systemd.h"
int
systemd_dir(void (**cb)(void))
{
char path[PATH_MAX];
if (syslib_randomdir(path) != 0)
return (-1);
systemd_journal("dir %s", path);
/* Recursively remove the directory. */
if (syslib_rmtree(path) != 0)
return (-1);
return (0);
}