Unable to add trusted=staff

64 views
Skip to first unread message

Charan

unread,
Sep 15, 2023, 1:28:12 AM9/15/23
to Tinode General
Hi,
Actually I tried to change a user to staff with help of root user through tn-cli. 
When I logged in with root user and tried to modify a particular user to "Staff", Firstly it triggered an error in client side stating expected bytes but found dict  then we changed a line in the code to 'encode_to_bytes" where the parse_trusted function is returning   its value .But still it is showing as  Request failed: 403 permission denied 
Below I have provided both client side and server side logs: 


With Original Code :
Tn-cli :
<= Authenticated as usrElwdqoKV9rc
<= 200 ok
tn> usermod usrPWavPlBrIbM --trusted=staff
<= Default user='usrPWavPlBrIbM'
<= 200 ok (me)
<= pres ON me
<= Error in 'set': expected bytes, dict found
<= 200 ok (me)
<= Default user='None'
Server :
I2023/09/15 10:00:09 grpc in: hi:{id:"11627" user_agent:"tn-cli/2.0.0b2 (Linux/5.19.0-41-generic); gRPC-python/0.22.3+1.58.0" ver:"0.22.3" lang:"EN"} 8xNWgy74dt0
I2023/09/15 10:00:09 grpc in: login:{id:"11628" scheme:"basic" secret:"xena:xena123"} 8xNWgy74dt0
I2023/09/15 10:00:46 grpc in: sub:{id:"11631" topic:"me" set_query:{desc:{default_acs:{}} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"} 8xNWgy74dt0
I2023/09/15 10:01:46 grpc in: leave:{id:"11633" topic:"me"} extra:{on_behalf_of:"usrPWavPlBrIbM"} 8xNWgy74dt

After Modifying the Code:
Tn-cli: 
<= 201 created
<= Authenticated as usrElwdqoKV9rc
<= 200 ok
tn> usermod usrPWavPlBrIbM --trusted=staff
<= Default user='usrPWavPlBrIbM'
<= 200 ok (me)
<= pres ON me
tn> Request failed: 403 permission denied
Shutting down...
Server :
I2023/09/15 10:04:46 grpc in: hi:{id:"50851" user_agent:"tn-cli/2.0.0b2 (Linux/5.19.0-41-generic); gRPC-python/0.22.3+1.58.0" ver:"0.22.3" lang:"EN"} 573OpIkBF5Y
I2023/09/15 10:04:46 grpc in: login:{id:"50852" scheme:"basic" secret:"xena:xena123"} 573OpIkBF5Y
I2023/09/15 10:05:03 grpc in: sub:{id:"50855" topic:"me" set_query:{desc:{default_acs:{}} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"} 573OpIkBF5Y
I2023/09/15 10:05:03 grpc in: set:{id:"50856" topic:"me" query:{desc:{default_acs:{} trusted:"{\"staff\": true}"} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"} 573Op
IkBF5Y
W2023/09/15 10:05:03 topic[usrPWavPlBrIbM] meta.Set.Desc failed: attempt to change Trusted by non-root

Gene

unread,
Sep 15, 2023, 1:02:00 PM9/15/23
to Tinode General
On Thursday, September 14, 2023 at 10:28:12 PM UTC-7 Charan wrote:
Hi,
Actually I tried to change a user to staff with help of root user through tn-cli. 
When I logged in with root user and tried to modify a particular user to "Staff", Firstly it triggered an error in client side stating expected bytes but found dict  then we changed a line in the code to 'encode_to_bytes" where the parse_trusted function is returning   its value .

Yes, it's indeed a bug. Thanks for pointing it out. Fixed in 

But still it is showing as  Request failed: 403 permission denied 

That's basically a missing feature in tn-cli. The auth_level value has to be set to ROOT but it's not set and there is no mechanism to set it.

        AuthLevel auth_level = 3;

I'll see how quickly I can add it.

Thanks.

Gene

unread,
Sep 15, 2023, 5:49:19 PM9/15/23
to Tinode General

Charan

unread,
Sep 20, 2023, 12:36:26 AM9/20/23
to Tinode General
Hi Gene,
Thank you very much for your response to the previous issue. 
We are now able to modify a user as staff. But when we tried to remove the staff access the user using --trusted=rm-staff , it's not working.
Below are tn-cli and server side logs: 

Client:
Tinode command line client. Version 2.0.0b2/0.22.3; gRPC/1.58.0; Python 3.10.6.
Server at 'localhost:16060'
Logging in with login:password xena:xena123
<= Connected to server: maxTagCount: 16; clusterSize: 1; build: rethinkdb:v0.22.10; servingAt: http://:6060/; maxSubscriberCount: 256; maxMessageSize: 262144; minTagLength
: 2; maxFileUploadSize: 8388608; ver: 0.22; reqCred: None; maxTagLength: 96
<= 201 created
<= Authenticated as usrElwdqoKV9rc
<= 200 ok

tn> usermod usrPWavPlBrIbM --as_root --trusted=rm-staff
<= Default user='usrPWavPlBrIbM'
<= 200 ok (me)
<= pres ON me
<= 200 ok (me)
<= 200 ok (me)
<= Default user='None'

tn> thecard --what=desc --as_root usrPWavPlBrIbM
<= Default user='usrPWavPlBrIbM'
<= 200 ok (me)
<= pres ON me
<= meta desc me
<= 200 ok (me)
<= Default user='None'
<= id: "52423"
topic: "me"
desc {
 created_at: 1694002372509
 updated_at: 1695183227931
 touched_at: 1695183227931
 defacs {
   auth: "JRWPAS"
   anon: "N"
 }
 acs {
   want: "JPS"
   given: "JPS"
 }
 public: "{\"fn\":\"Bob\",\"photo\":{\"data\":\"/9j/4AAQSkZJRgABAQAASABIAAD/.......... /ny3/2Q==\",\"type\":\"jpg\"}}"
 private: "{\"comment\":\"no comments :)\"}"
 state: "ok"
 trusted: "{\"\":true,\"staff\":true,\"verified\":true}"
}
 
tn> quit
Shutting down...

Server:
I2023/09/20 09:43:17 grpc in: login:{id:"52413" scheme:"basic" secret:"xena:xena123"} I8UlMkElfG8
I2023/09/20 09:43:47 grpc in: sub:{id:"52416" topic:"me" set_query:{desc:{default_acs:{}} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"} I8UlMkElfG8
I2023/09/20 09:43:47 grpc in: set:{id:"52417" topic:"me" query:{desc:{default_acs:{} trusted:"{\"staff\": \"\\u2421\"}"} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"
 auth_level:ROOT} I8UlMkElfG8
I2023/09/20 09:43:47 in: '{"get":{"id":"88252","topic":"me","what":"sub","sub":{"topic":"usrPWavPlBrIbM"}}}' sid='JHedw846Y4M' uid='kx_XC1rN1yo'
I2023/09/20 09:43:48 grpc in: leave:{id:"52418" topic:"me"} extra:{on_behalf_of:"usrPWavPlBrIbM"} I8UlMkElfG8
I2023/09/20 09:45:29 grpc in: sub:{id:"52422" topic:"me" set_query:{desc:{default_acs:{}} sub:{}}} extra:{on_behalf_of:"usrPWavPlBrIbM"} I8UlMkElfG8
I2023/09/20 09:45:30 grpc in: get:{id:"52423" topic:"me" query:{what:"desc"}} extra:{on_behalf_of:"usrPWavPlBrIbM"} I8UlMkElfG8
I2023/09/20 09:45:30 grpc in: leave:{id:"52424" topic:"me"} extra:{on_behalf_of:"usrPWavPlBrIbM"} I8UlMkElfG8 

Gene

unread,
Sep 20, 2023, 3:00:21 PM9/20/23
to Tinode General
Reply all
Reply to author
Forward
0 new messages