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>
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.2 |
7 |
-Release: 2%{?dist} |
|
7 |
+Release: 3%{?dist} |
|
8 | 8 |
Vendor: VMware, Inc. |
9 | 9 |
Distribution: Photon |
10 | 10 |
License: LGPLv2.1,GPLv2 |
... | ... |
@@ -28,6 +28,7 @@ Source2: cache-updateinfo.service |
28 | 28 |
Source3: cache-updateinfo.timer |
29 | 29 |
Source4: updateinfo.sh |
30 | 30 |
Patch0: tdnf_fix_protected_pkgs_in_obsolete.patch |
31 |
+Patch1: tdnf-perm.patch |
|
31 | 32 |
|
32 | 33 |
%description |
33 | 34 |
tdnf is a yum/dnf equivalent |
... | ... |
@@ -52,6 +53,7 @@ Library providing cli libs for tdnf like clients. |
52 | 52 |
%prep |
53 | 53 |
%setup -q |
54 | 54 |
%patch0 -p1 |
55 |
+%patch1 -p1 |
|
55 | 56 |
|
56 | 57 |
|
57 | 58 |
%build |
... | ... |
@@ -154,6 +156,8 @@ systemctl try-restart tdnf-cache-updateinfo.timer >/dev/null 2>&1 || : |
154 | 154 |
%{_libdir}/libtdnfcli.so.* |
155 | 155 |
|
156 | 156 |
%changelog |
157 |
+* Tue Jan 30 2018 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.2.2-3 |
|
158 |
+- patch to error out early for permission issues. |
|
157 | 159 |
* Tue Oct 10 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.2.2-2 |
158 | 160 |
- Fix bug in obsolete protected packages. |
159 | 161 |
* Wed Oct 4 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 1.2.2-1 |