Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate config files and directories with CMake #316

Merged

Conversation

hummeltech
Copy link
Collaborator

@hummeltech hummeltech commented Mar 14, 2023

Since most of the variables contained within config files and related to directory destinations are available at build time, they can be used to generate and install some of the config files and directories.

  • /etc/renderd.conf
    • Basic renderd configuration file with renderd & mapnik sections
  • /etc/apache2/mods-available/tile.load (path varies based on OS/Distribution)
    • Apache HTTP server LoadModule directive configuration file
  • /var/run/renderd
  • /var/cache/renderd/tiles

hummeltech added a commit to hummeltech/mod_tile that referenced this pull request Mar 14, 2023
@@ -191,7 +191,7 @@

int main(int argc, char **argv)
{
char spath[PATH_MAX] = RENDER_SOCKET;
char spath[PATH_MAX] = RENDERD_SOCKET;

Check notice

Code scanning / Flawfinder

Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120).

buffer/char:Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120).
@@ -320,7 +320,7 @@
fprintf(stderr, " -m, --map=STYLE Instead of going through all styls of CONFIG, only use a specific map-style\n");
fprintf(stderr, " -n, --num-threads=N the number of parallel request threads (default 1)\n");
fprintf(stderr, " -s, --socket=SOCKET|HOSTNAME:PORT unix domain socket name or hostname and port for contacting renderd\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" HASH_PATH "')\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" RENDERD_TILE_DIR "')\n");

Check notice

Code scanning / Flawfinder

If format strings can be influenced by an attacker, they can be exploited (CWE-134).

format/fprintf:If format strings can be influenced by an attacker, they can be exploited (CWE-134).
@@ -224,7 +224,7 @@
fprintf(stderr, " -m, --map=MAP render tiles in this map (defaults to '" XMLCONFIG_DEFAULT "')\n");
fprintf(stderr, " -n, --num-threads=N the number of parallel request threads (default 1)\n");
fprintf(stderr, " -s, --socket=SOCKET|HOSTNAME:PORT unix domain socket name or hostname and port for contacting renderd\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" HASH_PATH "')\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" RENDERD_TILE_DIR "')\n");

Check notice

Code scanning / Flawfinder

If format strings can be influenced by an attacker, they can be exploited (CWE-134).

format/fprintf:If format strings can be influenced by an attacker, they can be exploited (CWE-134).
@@ -2726,10 +2726,10 @@
scfg->max_load_old = MAX_LOAD_OLD;
scfg->max_load_missing = MAX_LOAD_MISSING;
scfg->veryold_threshold = VERYOLD_THRESHOLD;
strncpy(scfg->renderd_socket_name, RENDER_SOCKET, PATH_MAX - 1);
strncpy(scfg->renderd_socket_name, RENDERD_SOCKET, PATH_MAX - 1);

Check notice

Code scanning / Flawfinder

Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120).

buffer/strncpy:Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120).
scfg->renderd_socket_name[PATH_MAX - 1] = 0;
scfg->renderd_socket_port = 0;
strncpy(scfg->tile_dir, HASH_PATH, PATH_MAX - 1);
strncpy(scfg->tile_dir, RENDERD_TILE_DIR, PATH_MAX - 1);

Check notice

Code scanning / Flawfinder

Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120).

buffer/strncpy:Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120).
@@ -188,7 +188,7 @@
fprintf(stderr, "Usage: convert_meta [OPTION] ...\n");
fprintf(stderr, "Convert the rendered PNGs into the more efficient .meta format\n");
fprintf(stderr, " -m, --map convert tiles in this map (default is 'default')\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (default is '" HASH_PATH "')\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (default is '" RENDERD_TILE_DIR "')\n");

Check notice

Code scanning / Flawfinder

If format strings can be influenced by an attacker, they can be exploited (CWE-134).

format/fprintf:If format strings can be influenced by an attacker, they can be exploited (CWE-134).
@@ -206,7 +206,7 @@
fprintf(stderr, " -m, --map=MAP render tiles in this map (defaults to '" XMLCONFIG_DEFAULT "')\n");
fprintf(stderr, " -n, --num-threads=N the number of parallel request threads (default 1)\n");
fprintf(stderr, " -s, --socket=SOCKET|HOSTNAME:PORT unix domain socket name or hostname and port for contacting renderd\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" HASH_PATH "')\n");
fprintf(stderr, " -t, --tile-dir tile cache directory (defaults to '" RENDERD_TILE_DIR "')\n");

Check notice

Code scanning / Flawfinder

If format strings can be influenced by an attacker, they can be exploited (CWE-134).

format/fprintf:If format strings can be influenced by an attacker, they can be exploited (CWE-134).
@hummeltech hummeltech mentioned this pull request Mar 14, 2023
@hummeltech hummeltech force-pushed the CMakeGenerateConfigsAndDirectories branch from 40456c4 to 3f57e50 Compare June 4, 2023 18:27
@hummeltech hummeltech mentioned this pull request Jun 5, 2023
@pantierra
Copy link
Collaborator

Very nice improvement. Would love to merge it. Please rebase and resolve conflict. Thank you!

@hummeltech hummeltech force-pushed the CMakeGenerateConfigsAndDirectories branch from ea87849 to 6910cee Compare July 20, 2023 14:50
@hummeltech
Copy link
Collaborator Author

@xamanu Alright, I've rebased this and the tests are passing. Thanks!

@pantierra pantierra merged commit 6e20fba into openstreetmap:master Jul 20, 2023
@hummeltech hummeltech deleted the CMakeGenerateConfigsAndDirectories branch July 20, 2023 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants