From patchwork Tue Aug 3 01:07:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: muradm X-Patchwork-Id: 31757 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 24CEE27BC78; Tue, 3 Aug 2021 02:08:12 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AD35D27BC6B for ; Tue, 3 Aug 2021 02:08:11 +0100 (BST) Received: from localhost ([::1]:37660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAiug-0001U4-K8 for patchwork@mira.cbaines.net; Mon, 02 Aug 2021 21:08:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAiuY-0001Qu-Ti for guix-patches@gnu.org; Mon, 02 Aug 2021 21:08:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAiuY-00034w-Jg for guix-patches@gnu.org; Mon, 02 Aug 2021 21:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mAiuY-0003wF-Dw for guix-patches@gnu.org; Mon, 02 Aug 2021 21:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 03 Aug 2021 01:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49839 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49839@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162795284215088 (code B ref -1); Tue, 03 Aug 2021 01:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Aug 2021 01:07:22 +0000 Received: from localhost ([127.0.0.1]:39517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAitu-0003vI-HA for submit@debbugs.gnu.org; Mon, 02 Aug 2021 21:07:22 -0400 Received: from lists.gnu.org ([209.51.188.17]:52522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mAitt-0003vB-3y for submit@debbugs.gnu.org; Mon, 02 Aug 2021 21:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mAits-0000sr-V8 for guix-patches@gnu.org; Mon, 02 Aug 2021 21:07:20 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:36835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mAitr-0002b0-9I for guix-patches@gnu.org; Mon, 02 Aug 2021 21:07:20 -0400 Received: by mail-wr1-x42e.google.com with SMTP id b13so12562912wrs.3 for ; Mon, 02 Aug 2021 18:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=muradm-net.20150623.gappssmtp.com; s=20150623; h=user-agent:from:to:subject:date:message-id:mime-version; bh=uedXQP1M/6+ZtZbI1QN4NKpLDoN2clrTOpWQkHS390Q=; b=drrTuuSl+EI1mEAhEOJWf3zEabFL8c4L3i6JM8sn2tQII0posYVXwhzEqtx/eOFv3V YAqTx9xSAqsOWVsFq8bK/3hfRSwxRKdmo8umwcGA9yxsI7H2YhEr00QIOk+mUhVO2RGd iZgDHhnExfQqlqispK0rkQXLWXL7lNr8IWSf8it/cH6NkipWtmLZUPN2YYQLvQ2uA8FY 3PCdavTIcexJpVQZivdcj2fGgPNvAo6uDAfJLJIU+yYiuRR0IAV58N7DKN0ewvSxL0MU CNDEqBzCYb00qL6Q45RTANHIUWMa0SqAe6Nfi+e/pNqfEGuF5D0URQJRD4Fo8sa01BAD IvcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=uedXQP1M/6+ZtZbI1QN4NKpLDoN2clrTOpWQkHS390Q=; b=jy7dnsQWRCGNwr97e6JWCW4iZA07EkAF/QWfkyTCQ5R+5BNbIjNG9l77yZy/MF8kVb aMuGNWg235iaEelQOMVKfeirD+zLAlwDt1D7ZZ9zT0DWhsep/1AHfHmYy2ygZKm85GZh OolnvmMQTk8XD+qq/5/vnQxYOF9sIKAplsWnwjNnJo5UASW++OszPa5Geq+LNmd+O71w taaD9lYWkAHBbuQqrYljn/lfJ2Y+Jxrh6hIf9P0caGxF1Um/9Mwz6O/rewsvIQd2aA1i /i3FFycXgm++0JR6l87VHBa4bT3yVK3lZMjto+1Cbe1yfOBwl6NR4xlWUP2LGf+hnd0m Rb0A== X-Gm-Message-State: AOAM530qEm74UbaoYmdyAnm5LofD/u2JabGkKhH7w2wGokX3+IBdUvZA oZX6IrNbQMmPp+cfmeZGMAVOtvEbDgJSSD59Lew= X-Google-Smtp-Source: ABdhPJzxQgUTdkAvv2BK4HP/K5u3/HP1SbCAfbs7kqrqzJ1KXKNc3ba/aH1NPmVK8e7mosIU6hl0NA== X-Received: by 2002:a5d:4a4f:: with SMTP id v15mr19619498wrs.178.1627952836214; Mon, 02 Aug 2021 18:07:16 -0700 (PDT) Received: from nomad-lp1 ([31.142.116.101]) by smtp.gmail.com with ESMTPSA id i5sm12501272wrw.13.2021.08.02.18.07.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Aug 2021 18:07:14 -0700 (PDT) User-agent: mu4e 1.4.15; emacs 28.0.50 From: muradm Date: Tue, 03 Aug 2021 04:07:10 +0300 Message-ID: <87eebbwd35.fsf@muradm.net> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::42e; envelope-from=mail@muradm.net; helo=mail-wr1-x42e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * modules/shepherd/service.scm: add keep-tty flag to skip setsid when using shepherd as user, programs like xorg server, potentially any program which ends up interacting with user, require terminal to remain. currently, setsid is called unconditionally from exec-command function, making it impossible to have such process. this adds keep-tty flag to make-forkexec-constructor up to exec-command function where setsid is actually called. diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index 587ff68..1ae9544 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -786,6 +786,7 @@ daemon writing FILE is running in a separate PID namespace." (log-file #f) (directory (default-service-directory)) (file-creation-mask #f) + (keep-tty #f) (environment-variables (default-environment-variables))) "Run COMMAND as the current process from DIRECTORY, with FILE-CREATION-MASK if it's true, and with ENVIRONMENT-VARIABLES (a list of strings like @@ -804,7 +805,7 @@ false." ((program args ...) ;; Become the leader of a new session and session group. ;; Programs such as 'mingetty' expect this. - (setsid) + (unless keep-tty (setsid)) (chdir directory) (environ environment-variables) @@ -889,6 +890,7 @@ false." (log-file #f) (directory (default-service-directory)) (file-creation-mask #f) + (keep-tty #f) (environment-variables (default-environment-variables))) "Spawn a process that executed COMMAND as per 'exec-command', and return @@ -920,6 +922,7 @@ its PID." #:log-file log-file #:directory directory #:file-creation-mask file-creation-mask + #:keep-tty keep-tty #:environment-variables environment-variables)) pid)))) @@ -929,6 +932,7 @@ its PID." (group #f) (supplementary-groups '()) (directory (default-service-directory)) + (keep-tty #f) (environment-variables (default-environment-variables)) (file-creation-mask #f) @@ -949,7 +953,9 @@ When @var{pid-file} is true, it must be the name of a PID file associated with the process being launched; the return value is the PID read from that file, once that file has been created. If @var{pid-file} does not show up in less than @var{pid-file-timeout} seconds, the service is considered as failing to -start." +start. + +When @var{keep-tty} is true, will not call @code{setsid} for process." (lambda args (define (clean-up file) (when file @@ -969,6 +975,7 @@ start." #:log-file log-file #:directory directory #:file-creation-mask file-creation-mask + #:keep-tty keep-tty #:environment-variables environment-variables))) (if pid-file