PHP 8.2.30
Preview: crontab-user-wrapper.py Size: 2.46 KB
//opt/cloudlinux/venv/bin/crontab-user-wrapper.py

#!/opt/cloudlinux/venv/bin/python3 -sbb
# -*- coding: utf-8 -*-
#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2025 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENCE.TXT
#
"""
Crontab wrapper for website isolation support.

This wrapper mimics crontab command-line interface:
- crontab -l: Lists current crontab entries, filtering isolation tool prefixes
- crontab [file]: Installs crontab from file (or '-' for stdin)

When website isolation is active (PROXYEXEC_DOCUMENT_ROOT is set):
1. List operations filter out isolation wrapper prefixes from output
2. Save operations automatically prepend isolation tool to commands

The isolation tool is prepended to commands to ensure they run within the
isolated website context.
"""

import argparse
import sys

from clcagefslib.webisolation import crontab


def create_parser():
    """
    Create argument parser for the crontab wrapper.

    Returns:
        argparse.ArgumentParser: Configured argument parser
    """
    parser = argparse.ArgumentParser(
        prog="crontab-user-wrapper",
        description="Crontab wrapper for website isolation support. "
                    "Filters and modifies crontab entries to support website isolation.",
    )

    parser.add_argument(
        "-l",
        "--list",
        action="store_true",
        help="List current crontab entries (filters isolation prefixes)",
        dest="list_crontab",
    )

    parser.add_argument(
        "file",
        nargs="?",
        default="-",
        help="File containing crontab entries to install, or '-' to read from stdin (default: '-')",
    )

    return parser


def main(argv=None):
    """
    Main entry point.

    Args:
        argv: Command line arguments (defaults to sys.argv[1:])

    Returns:
        int: Exit code
    """
    parser = create_parser()
    args = parser.parse_args(argv)

    if args.list_crontab:
        return crontab.process_list()

    # Handle file argument: '-' means stdin, otherwise open the file
    if args.file == "-":
        stdin = sys.stdin.buffer
    else:
        try:
            stdin = open(args.file, "rb")
        except IOError as e:
            sys.stderr.write(f"crontab: error reading {args.file}: {e}\n")
            return 1

    try:
        return crontab.process_save(stdin=stdin)
    finally:
        if args.file != "-" and stdin != sys.stdin.buffer:
            stdin.close()


if __name__ == "__main__":
    sys.exit(main())

Directory Contents

Dirs: 0 × Files: 56

Name Size Perms Modified Actions
1.65 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
915 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download
2.14 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
8.82 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
202 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
12.89 KB lrwxr-xr-x 2026-03-02 11:08:26
Edit Download
1.83 KB lrwxr-xr-x 2026-03-02 11:08:26
Edit Download
210 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
3.64 KB lrwxr-xr-x 2026-02-10 15:06:06
Edit Download
4.51 KB lrwxr-xr-x 2026-02-10 15:06:06
Edit Download
204 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
204 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
204 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
3.83 KB lrwxr-xr-x 2026-02-10 15:06:06
Edit Download
2.46 KB lrwxr-xr-x 2026-03-02 11:08:26
Edit Download
686 B lrw-r--r-- 2026-02-10 15:06:06
Edit Download
211 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
197 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
208 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
205 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
205 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
205 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
203 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
204 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
1.84 KB lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
1.63 KB lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
198 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
232 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
202 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
1.12 KB lrw-r--r-- 2026-02-17 11:00:07
Edit Download
202 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
233 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
206 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
237 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
237 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
237 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
905 B lrw-r--r-- 2026-02-10 15:06:06
Edit Download
202 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
210 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
201 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
202 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
200 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
206 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
222 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
212 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
198 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
210 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
15.59 KB lrwxr-xr-x 2026-01-07 22:45:27
Edit Download
15.59 KB lrwxr-xr-x 2026-01-07 22:45:27
Edit Download
15.59 KB lrwxr-xr-x 2026-01-07 22:45:27
Edit Download
208 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
208 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
196 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
196 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
603 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download
227 B lrwxr-xr-x 2026-01-20 13:01:48
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).