How to change the date without being root?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to change the date without being root?

ソリューションへジャンプ
3,514件の閲覧回数
sandratrujillog
Contributor III

I use the development board T2080RDB-PC with Yocto QorIQSDK_v2.0. I have created users with restricted privileges using the useradd recipe. 

The problem is that for an application that I am developing I need to change the time often. How can these non-root users change the time? I just want these users to be able to change the date but remain users with restricted privileges.

Thanks.

0 件の賞賛
1 解決策
3,021件の閲覧回数
yipingwang
NXP TechSupport
NXP TechSupport

Hello Sandra Trujillo García,

Please add "sudo" in the rootfs package list, then modify date with sudo permission on the target board.

You also could use the command "setcap CAP_SYS_TIME+ep /bin/date", please add libcap into rootfs filesystem.

You could refer to permissions - Allow a specific user or group root access without password to /bin/date - Unix & Linu... for details.


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

3 返答(返信)
3,022件の閲覧回数
yipingwang
NXP TechSupport
NXP TechSupport

Hello Sandra Trujillo García,

Please add "sudo" in the rootfs package list, then modify date with sudo permission on the target board.

You also could use the command "setcap CAP_SYS_TIME+ep /bin/date", please add libcap into rootfs filesystem.

You could refer to permissions - Allow a specific user or group root access without password to /bin/date - Unix & Linu... for details.


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

3,021件の閲覧回数
sandratrujillog
Contributor III

I have managed to use the 'date' command without having to be a root user and without the need to enter the root password.
To do this we introduce the following command as root: # sudo visudo
Now the sudoers file will be opened and we will have to add the following line:

## My rules
Cmnd_Alias DATE = / bin / date
% group_name ALL = (root) NOPASSWD: DATE

Where group_name is the name of the group to which we want to give this permission, to know this name type the command 'groups' and the name of the user to whom you want to give permission

0 件の賞賛
3,021件の閲覧回数
sandratrujillog
Contributor III

I'm trying to use the capabilities (CAP_SYS_TIME) but when I run the "setcap CAP_SYS_TIME + ep / bin / date" command, I get the following error:

Failed to set capabilities on file '/bin/date' (Invalid argument)

usage: setcap [-q] [-v] (-r|-|<caps>) <filename> [ ... (-r|-|<capsN>) <filenameN> ]

   Note <filename> must be a regular (non-symlink) file.

Any suggestions?

0 件の賞賛