Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Username and Password from environment to enable scripting #40

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Optional arguments:
-h, --help Show this help message and exit
```

Additionally, AppleID user and password can be set via the environment variables `APPLE_ID_USER` and `APPLE_ID_PWD`.

Table of Contents
=================

Expand Down
21 changes: 13 additions & 8 deletions frontends/cli/source/cli_frontend.d
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,29 @@ DeveloperSession login(Device device, ADI adi, bool interactive) {
// ...

if (account) return null;
if (!interactive) {
string appleId = environment.get("APPLE_ID_USER");
string password = environment.get("APPLE_ID_PWD");
if(interactive && (appleId is null || password is null)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably do an interactive || here, as if the interactive switch is given it's probably to make the prompt appear.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think && is the better choice, as we want the prompt only in interactive mode - if there is no interactive mode, don't prompt, but fail - otherwise you'd receive a prompt in an non-interactive session.

For my use case I want to use this in an autonomous scripting scenario - failing in case input is required is exactly what I want :D

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just interactive then?

log.info("Please enter your account informations. They will only be sent to Apple servers.");
log.info("See it for yourself at https://github.com/Dadoum/Sideloader/");

write("Apple ID: ");
appleId = readln().chomp();
password = readPasswordLine("Password: ");
}

if (appleId is null || password is null) {
log.error("You are not logged in. (use `sidestore login` to log-in, or add `-i` to make us ask you the account)");
return null;
}

log.info("Please enter your account informations. They will only be sent to Apple servers.");
log.info("See it for yourself at https://github.com/Dadoum/Sideloader/");

write("Apple ID: ");
string appleId = readln().chomp();
string password = readPasswordLine("Password: ");

return DeveloperSession.login(
device,
adi,
appleId,
password,
(sendCode, submitCode) {
if(!interactive) return;
Dadoum marked this conversation as resolved.
Show resolved Hide resolved
sendCode();
string code;
do {
Expand Down
2 changes: 1 addition & 1 deletion source/usbmuxd/c.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ version (Windows) {
} else version (OSX) {
enum libusbmuxd = LibImport("libusbmuxd-2.0.6.dylib");
} else {
enum libusbmuxd = LibImport("libusbmuxd-2.0.so.6", "libusbmuxd.so.2");
enum libusbmuxd = LibImport("libusbmuxd-2.0.so.6", "libusbmuxd.so.2", "libusbmuxd-2.0.so");
}

mixin makeBindings;
Expand Down