Change-Id: I5e5edb067d961fcd5feac41323468d753defe9db
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4717
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Xiaolin Li <xiaolinl@vmware.com>
(cherry picked from commit 23d3838914346a356f9e533270e50aa08e19a5f3)
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4762
Reviewed-by: Priyesh Padmavilasom <ppadmavilasom@vmware.com>
Reviewed-by: Keerthana K <keerthanak@vmware.com>
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,49 @@ |
0 |
+diff --git a/client/defines.h b/client/defines.h |
|
1 |
+index 3eee2b6..aa2afc1 100644 |
|
2 |
+--- a/client/defines.h |
|
3 |
+@@ -212,4 +212,5 @@ typedef enum |
|
4 |
+ {ERROR_TDNF_RPM_CHECK, "ERROR_TDNF_RPM_CHECK", "rpm check reported errors"}, \ |
|
5 |
+ {ERROR_TDNF_METADATA_EXPIRE_PARSE, "ERROR_TDNF_METADATA_EXPIRE_PARSE", "metadata_expire value could not be parsed. Check your repo files."},\ |
|
6 |
+ {ERROR_TDNF_SELF_ERASE, "ERROR_TDNF_SELF_ERASE", "The operation would result in removing the protected package : tdnf"},\ |
|
7 |
++ {ERROR_TDNF_PERM, "ERROR_TDNF_PERM", "Operation not permitted. You have to be root."},\ |
|
8 |
+ }; |
|
9 |
+diff --git a/include/tdnferror.h b/include/tdnferror.h |
|
10 |
+index e858694..199c3a8 100644 |
|
11 |
+--- a/include/tdnferror.h |
|
12 |
+@@ -129,10 +129,11 @@ extern "C" { |
|
13 |
+ #define ERROR_TDNF_TRANS_INCOMPLETE 1525 |
|
14 |
+ #define ERROR_TDNF_TRANS_PKG_NOT_FOUND 1526 |
|
15 |
+ |
|
16 |
+-//System errors 1600 and up |
|
17 |
+-#define ERROR_TDNF_SYSTEM_BASE 1600 |
|
18 |
+ // No search results found |
|
19 |
+-#define ERROR_TDNF_NO_SEARCH_RESULTS 1601 |
|
20 |
++#define ERROR_TDNF_NO_SEARCH_RESULTS 1599 |
|
21 |
++#define ERROR_TDNF_SYSTEM_BASE 1600 |
|
22 |
++//System errors 1600 and up |
|
23 |
++#define ERROR_TDNF_PERM (ERROR_TDNF_SYSTEM_BASE + EPERM) |
|
24 |
+ #define ERROR_TDNF_INVALID_PARAMETER (ERROR_TDNF_SYSTEM_BASE + EINVAL) |
|
25 |
+ #define ERROR_TDNF_OUT_OF_MEMORY (ERROR_TDNF_SYSTEM_BASE + ENOMEM) |
|
26 |
+ #define ERROR_TDNF_NO_DATA (ERROR_TDNF_SYSTEM_BASE + ENODATA) |
|
27 |
+diff --git a/tools/cli/main.c b/tools/cli/main.c |
|
28 |
+index c0a2b5f..e6d6026 100644 |
|
29 |
+--- a/tools/cli/main.c |
|
30 |
+@@ -63,6 +63,15 @@ int main(int argc, char* argv[]) |
|
31 |
+ PTDNF pTdnf = NULL; |
|
32 |
+ int nFound = 0; |
|
33 |
+ |
|
34 |
++ //granular permissions for non root users are pending. |
|
35 |
++ //blocking all operations for non root and show the |
|
36 |
++ //right error to avoid confusion. |
|
37 |
++ if(geteuid() != 0) |
|
38 |
++ { |
|
39 |
++ dwError = ERROR_TDNF_PERM; |
|
40 |
++ BAIL_ON_CLI_ERROR(dwError); |
|
41 |
++ } |
|
42 |
++ |
|
43 |
+ _context.pFnCheck = TDNFCliInvokeCheck; |
|
44 |
+ _context.pFnCheckLocal = TDNFCliInvokeCheckLocal; |
|
45 |
+ _context.pFnCheckUpdate = TDNFCliInvokeCheckUpdate; |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
Summary: dnf/yum equivalent using C libs |
5 | 5 |
Name: tdnf |
6 | 6 |
Version: 1.2.3 |
7 |
-Release: 5%{?dist} |
|
7 |
+Release: 6%{?dist} |
|
8 | 8 |
Vendor: VMware, Inc. |
9 | 9 |
Distribution: Photon |
10 | 10 |
License: LGPLv2.1,GPLv2 |
... | ... |
@@ -30,6 +30,7 @@ Source4: updateinfo.sh |
30 | 30 |
Patch0: tdnf_add_retry_to_downloads.patch |
31 | 31 |
Patch1: tdnf_fix_curl_getinfo_type.patch |
32 | 32 |
Patch2: tdnf-updateinfo.patch |
33 |
+Patch3: tdnf-perm.patch |
|
33 | 34 |
|
34 | 35 |
%description |
35 | 36 |
tdnf is a yum/dnf equivalent |
... | ... |
@@ -56,6 +57,7 @@ Library providing cli libs for tdnf like clients. |
56 | 56 |
%patch0 -p1 |
57 | 57 |
%patch1 -p1 |
58 | 58 |
%patch2 -p1 |
59 |
+%patch3 -p1 |
|
59 | 60 |
|
60 | 61 |
%build |
61 | 62 |
sed -i 's/tdnf, 1.2.0/tdnf, 1.2.3/' configure.ac |
... | ... |
@@ -157,6 +159,8 @@ systemctl try-restart tdnf-cache-updateinfo.timer >/dev/null 2>&1 || : |
157 | 157 |
%{_libdir}/libtdnfcli.so.* |
158 | 158 |
|
159 | 159 |
%changelog |
160 |
+* Fri Jan 04 2019 Keerthana K <keerthanak@vmware.com> 1.2.3-6 |
|
161 |
+- patch to error out early for permission issues. |
|
160 | 162 |
* Sat Oct 27 2018 Keerthana K <keerthanak@vmware.com> 1.2.3-5 |
161 | 163 |
- Fix bug in update and updateinfo. |
162 | 164 |
* Fri Sep 14 2018 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.2.3-4 |