lastpass / lastpass-cli

LastPass command line interface tool
GNU General Public License v2.0
2.85k stars 292 forks source link

Share created but Error: Share ... not found #515

Open TinajaLabs opened 5 years ago

TinajaLabs commented 5 years ago

When using lpass and after logging in I can create a shared folder but after creating it, it cannot be listed or accessed. Examples:

$ lpass share create Shared-Passwords-my
Folder Shared-Passwords-my created.

$ lpass ls Shared-Passwords-my
$

$ lpass share useradd --read-only=true --hidden=false --admin=false Shared-Passwords-my chris@my.net
Error: Share Shared-Passwords-my not found.

Also I cannot see it in the web ui...

Any tips appreciated. Thanks, Chris.

au-andrew commented 4 years ago

I also am experiencing this. Any known work arounds or eta on a fix?

HARVS1789UK commented 4 years ago

I am also experiencing this issue, seeming intermittently and seemingly not following any obvious pattern.

My C is pretty much non-existent, but I have looked at the share_create() method and the lastpass_share_create() method which it uses.

I am not sure, but I think the reason that lpass share create [SHARENAME] doesn't take a --sync parameter is because it syncs immediately at all times (could anyone confirm)?

I have considered the below as potential issues:

but from my tests, trying examples to intentionally fall foul of the above possible causes has been seen to work as expected at times and fail at others?

I can confirm whether or not the share has indeed been created as suggested by the response message (Note: it displays this message wether it worked or not) by doing an lpass ls immediatly after the lpass share create [SHARENAME] call is made. If the new share can be seen in the list, it worked, if it can't, it failed (and therefore all future share subcommands in this share will also fail, as per the OP's comments)

Examples of share names I have tried:

I am not seeing anything left over in my .lpass/upload-queue directory to suggest it's an issue with the sync process getting stuck.

Could one of the contributors (@bcopeland perhaps?) pass comment on this one? Seems like a pretty fundamental issue limiting the use of all the share subcommands essentially?

HARVS1789UK commented 4 years ago

Also worth noting, although I have seen this same issue during manual Cli usage, I am currently trying to implement this via a bash script (see below) and have considered that the lpass share create [SHARENAME] command might execute asynchronously and my follow up commands might be executing before the new share exists (though based on a 2-3 seconds it takes to respond with 'Folder "Shared-MyFolder" created', it seems like it's probably synchronous?).

I have even added a do...while loop to keep checking the share exists before I try to call useradd, this seems to stop the issues with useradd but still it throws errors when I try to do a lpass mv into the share (even though it 100% exists!).

I am calling the script passing 3 parameters as below:

sh ./newStarterLastPassSetup 'John Smith' 'john.smith@example.com' 'P@ssW0rD'

with the contents of ./newStarterLastPassSetup being:

#!/bin/bash

FULLNAME=$1
USERNAME=$2
PASSWORD=$3

FAILED_SHARE_LOOKUPS=0

# Create new shared folder 
lpass share create "${FULLNAME}_Logins"

while :
do
    # Try to list details about the new share (which may or may not exist yet)
    lpass share userls "Shared-${FULLNAME}_Logins" &> ./latest_share_userls_output.txt

    # Evaluate the exit code of our last request (0 = Success, 1 = Error)
    if [ ${?} -ne 0 ]
    then
        # If error, increment the failure counter by 1
        FAILED_SHARE_LOOKUPS=$((FAILED_SHARE_LOOKUPS+1))

        # Check how many failures we have had
        if [ $FAILED_SHARE_LOOKUPS -le 6 ]
        then
            # If lower than or equal to our failure threshold, pause for 5 seconds and try again
            echo "Waiting for share to be created..."
            sleep 5
        else 
            # If above our failure threshold, abort the rest of the script
            echo "Failed to find newly created share after $FAILED_SHARE_LOOKUPS attempts! Quitting..."
            exit 1
        fi
    else
        # If success, break out of the loop and continue to act on share
        break
    fi
done

# Provide admin access to Directors
lpass share useradd --read-only=false --hidden=false --admin=true "Shared-${FULLNAME}_Logins" "director.one@my.co"
lpass share useradd --read-only=false --hidden=false --admin=true "Shared-${FULLNAME}_Logins" "director.two@my.co"

# Sync share creation and access provision (not sure if needed, but doesn't hurt)
lpass sync 

# Create new site for existing Azure AD/Microsoft credentials and move to shared folder
printf "Name: $FULLNAME - Microsoft Account - My Company \nURL: https://login.microsoftonline.com \nUsername: $USERNAME\nPassword: $PASSWORD\n" | lpass add --non-interactive --sync=no "$FULLNAME - Microsoft Account - My Company"
lpass mv --sync=no "$FULLNAME - Microsoft Account - My Company" "Shared-${FULLNAME}_Logins"

# Generate new credentials for 'Service X' and move to shared folder
lpass generate --sync=no --username=$USERNAME --url="https://example.com/" "$FULLNAME - Example System - My Company" 24
lpass mv --sync=no "$FULLNAME - Slack - Nexus" "Shared-${FULLNAME}_Logins"

# Synchronise local vault with LastPass servers
lpass sync