diff --git a/.gitignore b/.gitignore
index 00cebf9..1a9e688 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-SOURCES/rhc-0.2.1.tar.gz
+SOURCES/rhc-0.2.2.tar.gz
SOURCES/yggdrasil-0.2.1.tar.gz
SOURCES/yggdrasil-worker-package-manager-0.1.0.tar.gz
diff --git a/.rhc.metadata b/.rhc.metadata
index bce74d3..725a0bf 100644
--- a/.rhc.metadata
+++ b/.rhc.metadata
@@ -1,3 +1,3 @@
-2209827b582aff0a0ddea854c116de223e8ee604 SOURCES/rhc-0.2.1.tar.gz
+7f90428c84e86660930463c8f31765c023dea8c7 SOURCES/rhc-0.2.2.tar.gz
55a3abc8515dede8b7ff41905447e08f5e6c01d7 SOURCES/yggdrasil-0.2.1.tar.gz
0582350e1001af0d608772860045f7f4964aa321 SOURCES/yggdrasil-worker-package-manager-0.1.0.tar.gz
diff --git a/SOURCES/0001-fix-read-worker-output-using-io.Read.patch b/SOURCES/0001-fix-read-worker-output-using-io.Read.patch
new file mode 100644
index 0000000..c33e4f3
--- /dev/null
+++ b/SOURCES/0001-fix-read-worker-output-using-io.Read.patch
@@ -0,0 +1,89 @@
+From d75dc60df73a88b0a14c799f3b6f1e8f66cee3d4 Mon Sep 17 00:00:00 2001
+From: Link Dupont
+Date: Tue, 22 Nov 2022 13:07:41 -0500
+Subject: [PATCH] fix: read worker output using io.Read
+
+Some workers output a lot of text to stderr and stdout. Rather than
+scanning stderr and stdout into a buffer using a bufio.Scanner, read a
+fixed number of bytes at a time. This will break lines of output from
+the worker in the middle of words, making reading stdout in the logs
+more difficult, but avoids the overly verbose workers from hitting the
+bufio.ErrTooLong error.
+
+Signed-off-by: Link Dupont
+---
+ cmd/yggd/exec.go | 46 +++++++++++++++++++++++++++++++++-------------
+ 1 file changed, 33 insertions(+), 13 deletions(-)
+
+diff --git a/cmd/yggd/exec.go b/cmd/yggd/exec.go
+index 4eb1757..a2a3d29 100644
+--- a/cmd/yggd/exec.go
++++ b/cmd/yggd/exec.go
+@@ -1,8 +1,8 @@
+ package main
+
+ import (
+- "bufio"
+ "fmt"
++ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+@@ -54,22 +54,42 @@ func startProcess(file string, env []string, delay time.Duration, died chan int)
+ log.Debugf("started process: %v", cmd.Process.Pid)
+
+ go func() {
+- scanner := bufio.NewScanner(stdout)
+- for scanner.Scan() {
+- log.Tracef("[%v] %v", file, scanner.Text())
+- }
+- if err := scanner.Err(); err != nil {
+- log.Errorf("cannot read from stdout: %v", err)
++ for {
++ buf := make([]byte, 4096)
++ n, err := stdout.Read(buf)
++ if n > 0 {
++ log.Tracef("[%v] %v", file, strings.TrimRight(string(buf), "\n\x00"))
++ }
++ if err != nil {
++ switch err {
++ case io.EOF:
++ log.Debugf("%v stdout reached EOF: %v", file, err)
++ return
++ default:
++ log.Errorf("cannot read from stdout: %v", err)
++ continue
++ }
++ }
+ }
+ }()
+
+ go func() {
+- scanner := bufio.NewScanner(stderr)
+- for scanner.Scan() {
+- log.Errorf("[%v] %v", file, scanner.Text())
+- }
+- if err := scanner.Err(); err != nil {
+- log.Errorf("cannot read from stderr: %v", err)
++ for {
++ buf := make([]byte, 4096)
++ n, err := stderr.Read(buf)
++ if n > 0 {
++ log.Errorf("[%v] %v", file, strings.TrimRight(string(buf), "\n\x00"))
++ }
++ if err != nil {
++ switch err {
++ case io.EOF:
++ log.Debugf("%v stderr reached EOF: %v", file, err)
++ return
++ default:
++ log.Errorf("cannot read from stderr: %v", err)
++ continue
++ }
++ }
+ }
+ }()
+
+--
+2.38.1
+
diff --git a/SOURCES/0003-fix-collect-error-messages-during-disconnect.patch b/SOURCES/0003-fix-collect-error-messages-during-disconnect.patch
deleted file mode 100644
index 19d2a5b..0000000
--- a/SOURCES/0003-fix-collect-error-messages-during-disconnect.patch
+++ /dev/null
@@ -1,102 +0,0 @@
-From 0e3ce2489f92cc037936866a1d6d7901fb14d440 Mon Sep 17 00:00:00 2001
-From: Link Dupont
-Date: Mon, 14 Feb 2022 15:15:54 -0500
-Subject: [PATCH] fix: collect error messages during disconnect
-
-If an error occurs during disconnect, the error is collected and
-reported at the end of the operation instead of aborting the operation
-part-way through.
-
-Fixes: ESSNTL-2281
----
- main.go | 42 +++++++++++++++++++++++++++++++++---------
- 1 file changed, 33 insertions(+), 9 deletions(-)
-
-diff --git a/main.go b/main.go
-index 0e6cc07..db5a34d 100644
---- a/main.go
-+++ b/main.go
-@@ -6,6 +6,7 @@ import (
- "fmt"
- "os"
- "strings"
-+ "text/tabwriter"
- "time"
-
- "git.sr.ht/~spc/go-log"
-@@ -18,6 +19,7 @@ import (
-
- const successPrefix = "\033[32m●\033[0m"
- const failPrefix = "\033[31m●\033[0m"
-+const errorPrefix = "\033[31m!\033[0m"
-
- func main() {
- app := cli.NewApp()
-@@ -169,6 +171,7 @@ func main() {
- UsageText: fmt.Sprintf("%v disconnect", app.Name),
- Description: fmt.Sprintf("The disconnect command disconnects the system from Red Hat Subscription Management, Red Hat Insights and %v and deactivates the %v daemon. %v will no longer be able to interact with the system.", Provider, BrandName, Provider),
- Action: func(c *cli.Context) error {
-+ errorMessages := make(map[string]error)
- hostname, err := os.Hostname()
- if err != nil {
- return cli.Exit(err, 1)
-@@ -180,29 +183,50 @@ func main() {
- s.Suffix = fmt.Sprintf(" Deactivating the %v daemon", BrandName)
- s.Start()
- if err := deactivate(); err != nil {
-- return cli.Exit(err, 1)
-+ errorMessages[BrandName] = fmt.Errorf("cannot deactivate daemon: %w", err)
-+ s.Stop()
-+ fmt.Printf(errorPrefix+" Cannot deactivate the %v daemon\n", BrandName)
-+ } else {
-+ s.Stop()
-+ fmt.Printf(failPrefix+" Deactivated the %v daemon\n", BrandName)
- }
-- s.Stop()
-- fmt.Printf(failPrefix+" Deactivated the %v daemon\n", BrandName)
-
- s.Suffix = " Disconnecting from Red Hat Insights..."
- s.Start()
- if err := unregisterInsights(); err != nil {
-- return cli.Exit(err, 1)
-+ errorMessages["insights"] = fmt.Errorf("cannot disconnect from Red Hat Insights: %w", err)
-+ s.Stop()
-+ fmt.Printf(errorPrefix + " Cannot disconnect from Red Hat Insights\n")
-+ } else {
-+ s.Stop()
-+ fmt.Print(failPrefix + " Disconnected from Red Hat Insights\n")
- }
-- s.Stop()
-- fmt.Print(failPrefix + " Disconnected from Red Hat Insights\n")
-
- s.Suffix = " Disconnecting from Red Hat Subscription Management..."
- s.Start()
- if err := unregister(); err != nil {
-- return cli.Exit(err, 1)
-+ errorMessages["rhsm"] = fmt.Errorf("cannot disconnect from Red Hat Subscription Management: %w", err)
-+ s.Stop()
-+ fmt.Printf(errorPrefix + " Cannot disconnect from Red Hat Subscription Management\n")
-+ } else {
-+ s.Stop()
-+ fmt.Printf(failPrefix + " Disconnected from Red Hat Subscription Management\n")
- }
-- s.Stop()
-- fmt.Printf(failPrefix + " Disconnected from Red Hat Subscription Management\n")
-
- fmt.Printf("\nManage your Red Hat connector systems: https://red.ht/connector\n")
-
-+ if len(errorMessages) > 0 {
-+ fmt.Println()
-+ fmt.Printf("The following errors were encountered during disconnect:\n\n")
-+ w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
-+ fmt.Fprintln(w, "STEP\tERROR\t")
-+ for svc, err := range errorMessages {
-+ fmt.Fprintf(w, "%v\t%v\n", svc, err)
-+ }
-+ w.Flush()
-+ return cli.Exit("", 1)
-+ }
-+
- return nil
- },
- },
diff --git a/SPECS/rhc.spec b/SPECS/rhc.spec
index 8e974cf..b4234f3 100644
--- a/SPECS/rhc.spec
+++ b/SPECS/rhc.spec
@@ -1,5 +1,3 @@
-%define debug_package %{nil}
-
%global buildflags -buildmode pie -compiler gc -a -v -x
%global goldflags %{expand:-linkmode=external -compressdwarf=false -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags'}
@@ -7,8 +5,8 @@
%global ygg_pkg_mgr_ver 0.1.0
Name: rhc
-Version: 0.2.1
-Release: 9%{?dist}
+Version: 0.2.2
+Release: 1%{?dist}
Epoch: 1
Summary: rhc connects the system to Red Hat hosted services
License: GPLv3
@@ -22,13 +20,15 @@ Source4: rhc-package-manager.toml
# Fixed upstream https://github.com/RedHatInsights/yggdrasil-worker-package-manager/commit/22105b0016abfc7c743c1eadb0372e4ef93cc65e
Patch0: 0001-feat-default-config-file-location.patch
-# Fixed upstream https://github.com/RedHatInsights/rhc/commit/0e3ce2489f92cc037936866a1d6d7901fb14d440
-Patch1: 0003-fix-collect-error-messages-during-disconnect.patch
+# Fixed upstream https://github.com/RedHatInsights/yggdrasil/pull/100/commits/d75dc60df73a88b0a14c799f3b6f1e8f66cee3d4
+Patch2: 0001-fix-read-worker-output-using-io.Read.patch
ExclusiveArch: %{go_arches}
Recommends: insights-client
+Requires(post): policycoreutils-python-utils
+
BuildRequires: git
BuildRequires: golang
BuildRequires: go-rpm-macros
@@ -60,7 +60,7 @@ This package includes files necessary for building rhc workers.
SHORTNAME=%{name} \\
LONGNAME=%{name} \\
PKGNAME=%{name} \\
- 'BRANDNAME=Red Hat connector' \\
+ 'BRANDNAME=Remote Host Configuration' \\
TOPICPREFIX=redhat/insights \\
VERSION=%{version} \\
DATAHOST=cert.cloud.redhat.com \\
@@ -75,8 +75,8 @@ sed -i -e "s/LDFLAGS :=/LDFLAGS ?=/" %{_builddir}/%{name}/yggdrasil-%{yggdrasil_
sed -i -e "s/LDFLAGS :=/LDFLAGS ?=/" %{_builddir}/%{name}/%{name}-%{version}/Makefile
cd %{_builddir}/%{name}/yggdrasil-worker-package-manager
%patch0 -p0
-cd %{_builddir}/%{name}/%{name}-%{version}
-%patch1 -p1
+cd %{_builddir}/%{name}/yggdrasil-%{yggdrasil_ver}
+%patch2 -p1
%build
@@ -114,6 +114,20 @@ make %{makeflags} \
install
+%post
+if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+ /usr/sbin/semanage permissive --add rhcd_t || true
+fi
+
+
+%postun
+if [ $1 -eq 0 ]; then
+ if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
+ /usr/sbin/semanage permissive --delete rhcd_t || true
+ fi
+fi
+
+
%files
%doc %{name}-%{version}/README.md yggdrasil-%{yggdrasil_ver}/doc/tags.toml
%{_bindir}/%{name}
@@ -131,6 +145,25 @@ make %{makeflags} \
%changelog
+* Tue Feb 14 2023 Alba Hita Catala - 0.2.2-1
+- New upstream version (RHBZ#2169772)
+- RHC renaming (RHBZ#2167427)
+
+* Wed Feb 01 2023 Link Dupont - 1:0.2.1-14
+- Correct syntax error in post scriptlet
+
+* Fri Jan 27 2023 Link Dupont - 0.2.1-13
+- Build debuginfo packages
+
+* Thu Jan 26 2023 Link Dupont - 0.2.1-12
+- Only run semanage conditionally when SELinux is enabled (RHBZ#2164602)
+
+* Tue Nov 22 2022 Link Dupont - 0.2.1-11
+- Fix an issue scanning worker's stdout (RHBZ#2144926)
+
+* Thu Nov 10 2022 Link Dupont - 0.2.1-10
+- Set SELinux policy to permissive for rhcd_t module (RHBZ#2141445)
+
* Fri Jun 03 2022 Link Dupont - 0.2.1-9
- Correct config file installation name (RHBZ#2082689)