upstream closed with this note

'That's to be expected. The D-Bus socket for the session bus is located in 
$XDG_RUNTIME_DIR, which is user-specific. When you use sudo, the command that 
is started by it doesn't have the $XDG_RUNTIME_DIR envvar set (or anything 
related to the current session basically), so it can't do anything with it.
See also 
https://unix.stackexchange.com/questions/346841/why-does-sudo-i-not-set-xdg-runtime-dir-for-the-target-user
 . The fact that this once used to work, is also explained there.
Closing this as this is really not a bug, let alone one of libsecret'

** Changed in: gnome-keyring (Ubuntu)
       Status: Triaged => Invalid

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to gnome-keyring in Ubuntu.
https://bugs.launchpad.net/bugs/1915897

Title:
  libsecret not working with user account space for ubuntu2004

Status in GNOME Keyring:
  Fix Released
Status in gnome-keyring package in Ubuntu:
  Invalid

Bug description:
  I am using libsecret library and facing problem with ubuntu2004 gnome-keyring
  I have written below cpp code

  #include<libsecret/secret.h>
  #include<iostream>
  #include<time.h>
  #defineSCHEMAgetSchema()
  #defineCREDENTIALS_TOKEN_LABEL"ubuntu2004test"

  
  constSecretSchema*getSchema(void)
  {

  staticconst SecretSchema schema = {
  "org.example.credentials",
  SECRET_SCHEMA_NONE,
  {
  {"username", SECRET_SCHEMA_ATTRIBUTE_STRING},
  {NULL, (SecretSchemaAttributeType)0}}};

  return &schema;
  }

  voidputCredentials(std::stringusername,std::stringpassword)
  {
  GError *error = NULL;
  secret_password_store_sync(SCHEMA, SECRET_COLLECTION_DEFAULT, 
CREDENTIALS_TOKEN_LABEL, password.c_str(), NULL,
  &error, "username",username.c_str(),NULL);
  }
  voiddeleteAllCredentials(){
  std::cout<<"\nDeletting all credential....\n";
  GError *error = NULL;
  SecretService *sec = secret_service_get_sync(SECRET_SERVICE_LOAD_COLLECTIONS, 
NULL, &error);
  _SecretCollection *collection = NULL;

  collection = secret_collection_for_alias_sync(sec, SECRET_COLLECTION_DEFAULT,
  SECRET_COLLECTION_LOAD_ITEMS, NULL, &error);
  GList *items = secret_collection_get_items(collection);
  for (unsignedinti = 0; i < g_list_length(items); i++)
  {
  SecretItem *item = (SecretItem *)g_list_nth_data(items, i);
  std::stringlabel(secret_item_get_label(item));
  if (label==CREDENTIALS_TOKEN_LABEL)
  {
  secret_item_delete_sync(item, NULL, &error);
  if (error != NULL)
  {
  std::cout<<"Error: Cannot delete item:"<<error->message;
  }
  }
  g_object_unref(item);
  }
  g_list_free(items);
  std::cout<<"...All credentials deleted...";
  }

  intmain()
  {
  std::cout<<"Adding tokens";
  std::cout<<"\nEnter new username or type exit :";
  std::stringusername[] = {"user1", "user2", "user3", "user4", "user5", 
"user6"};
  std::stringpassword[] = {"pass1", "pass2", "pass3", "pass4", "pass5", 
"pass6"};

  for (inti = 0; i < 6; i++)
  {
  std::cout<<"Adding credentials....\n";
  std::cout<<username[i]<<std::endl;
  std::cout<<password[i]<<std::endl;
  putCredentials(username[i], password[i]);
  sleep(3);
  }
  deleteAllCredentials();
  return0;
  }


  And I compile it using
  g++ ubuntu2004-libsecret.cpp -o test `pkg-config --cflags --libs glib-2.0 
libsecret-1`

  I have below shell script
  #!/bin/bash
  location="/home/avinash/Documents/training/"
  EXE_CMD=$location"test"
  echo$EXE_CMD
  if [ `whoami` = "root" ]
  then
  echo"adding in user account: "`logname`
  runuser -l `logname` -c "$EXE_CMD 2>/dev/null"
  else
  $EXE_CMD 2>/dev/null

  fi


  
  I get below results "sh ./
  Ubuntu 1804: users added and removed in user account ,with and without sudo
  Ubuntu 2004: users added and removed in user account only without sudo, sudo 
run does not add and remove credentials to user account here.

  Any help for ubuntu2004 will be appreciated.

To manage notifications about this bug go to:
https://bugs.launchpad.net/gnome-keyring/+bug/1915897/+subscriptions


-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to