Thanks, below is the upstream logged issue.
https://gitlab.gnome.org/GNOME/libsecret/-/issues/57

** Bug watch added: gitlab.gnome.org/GNOME/libsecret/-/issues #57
   https://gitlab.gnome.org/GNOME/libsecret/-/issues/57

-- 
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 package in Ubuntu:
  New

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/ubuntu/+source/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