How to install applet with default select - javacard

I want to install an applet in the java card, but I don't want to select it when inserted in card reader.
I want to send A404000A 504159464C4558503553 as my first command. I checked and found that install with -d in JCOP can solve my purpose, but where I set it?
Currently, my JCOP tool sending install command looks like:
install -i 504159464c4558503553 -q C9#() a0a1a2a3a4a5 a0a1a2a3a4a5a6
but i want jcop send -d too. Perhaps it will solve my purpose.
how can I set -d in JCOP?

-d is equal to --default and will mark the applet as default selected. This means that the applet is selected as soon as the card is put into the reader and ATR/ATS is issued. Unfortunatly your question is not clearly stated if this behaviour is desired or not. Usage for JCOP Shell install command is:
install [-e|--delegation][-l|--cm-lock][-t|--terminate][-d|--default][-p|--pin-change][-s|--security-domain][-b|--sd-dap][-m|--mandated-dap][-q|--install-param params][-i|--instance-aid AID][-o|--install-only] pkgAID appAID
The order of optional arguments is not evaluated, so for example use:
install -i 504159464c4558503553 -d -q C9#() a0a1a2a3a4a5 a0a1a2a3a4a5a6

Related

Confused about install -m and install -d using Yocto

I have taken over a Yocto project, and inside a .bb recipe file, I see the following lines to install new directories in the image:
do_install() {
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app/apiary
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app/lib
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app/config
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app/scripts
install -m 0755 -d ${DEPLOY_DIR_IMAGE}/app/keys
This works but I am confused. From my reading about Yocto and doing do_install, I thought that the -m option is only for installing files and not directories.
What is the effect of doing install -m 0755 -d , both the -m and -d options with the install command?
Also, why is there no ${D} variable like in the majority of other directory installations which I see?
I normally wouldn't resort to Stack Overflow for a question like this, but there is so much inconsistency that I don't understand , and hard to find an answer.
The task in question is defined as a shell function. The install command used within is a shell command, not anything Yocto- or BitBake-specific, so you should be looking at its docs for enlightenment, not relying on BitBake documentation or examples. In the context of Yocto in particular, however, you should be looking at the documentation for the GNU coreutils version of the install program (as linked above), which is the one you will invariably find on Linux systems.*
From my reading about Yocto and doing do_install, I thought that the -m option is only for installing files and not directories.
I'm not sure what would make you think that, other than just not seeing it applied to directories before.
What is the effect of doing install -m 0755 -d, both the -m and -d options with the install command?
The -m option sets the mode (access-control bits) of the installed object(s). Directories have modes just like regular files do, and the -m option has the same meaning for installing directories as it does for installing regular files.
The -d option specifies that the names specified for installation are to be taken as directories to be created, along with any missing directories in the specified path. As #jww observed in comments, the effect is analogous to that of mkdir -p.
These options are orthogonal. When used together, their effects combine in the natural way: the specified directories are created, with parent directories if needed, and all directories created are assigned the specified mode. Setting the modes explicitly to 0755 is superfluous, however, because that's the default. That may be why you are not used to seeing -m options used for directories.
Also, why is there no ${D} variable like in the majority of other directory installations which I see?
The Yocto specifications for do_install say that it should install files relative to ${D}, whereas the variable DEPLOY_DIR_IMAGE refers to the location for ready-to-install images. It seems like installing to ${DEPLOY_DIR_IMAGE} would be the wrong thing to do, but that doesn't necessarily mean that it wouldn't produce the desired ultimate effect. Or perhaps the recipe was simply written for some older version of BitBake where it made more sense. In any event, sorting out the the details would be a much deeper and more involved analysis than I am prepared to perform for you.
*install is not standardized by POSIX. The GNU version was inspired by BSD's program of the same name, and current versions of that have similar options and behavior, including specifically with respect to the -m and -d options.

How Do I Create A User & Set Password Without User Interaction?

I have been recently working on a project named: arch loop, which is an automated installer for Arch Linux. I have seen a few installers and scripts to make Arch installation easier, but I am someone who installs Arch Linux, more than three times a day, so following the Arch-way takes a long time and constantly requires user interaction.
The Problem:
The password is, the information about non-root user is to be created is taken before itself, and when the appropriate time comes, we will be using the following command:
arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/bash archuser
arch-chroot /mnt bash -c "echo -e 'password\npassword\n' | passwd
arch-chroot /mnt bash -c "echo -e 'rootpassword\nrootpassword\n' | passwd root
to send the password to passwd binary in the chroot system. But I don't know why it does not work. When the password is being verified by the sudo command after the installation is finished. The password seems to be perfectly working. But when tried to log in with the non-root user from tty, the password seems to be incorrect.
Things I Have Already Tried:
Manually encrypting the provided password with the below code and passing it to the useradd binary with -p option:
perl -e 'print crypt("password", "\$6\$SALTsalt\$") . "\n"'"
Please guide me on how to set a user's provided password at a later time, without requiring any user interaction.
Thank You :)
There exists the chpasswd command. It is just there only to make passwd available in batch scripts. Just do:
echo "root:rootpassword" | arch-chroot /mnt chpasswd
or maybe better, without the need for mount -o bind the sys proc and dev directories:
echo "root:rootpassword" | chpasswd -R /mnt
#subjective: Sorry for the opinion, the project looks ok, however much more work is to be done. I guess the aim is to bring Archlinux closer to "normal" users. However, I don't like the choose of python for the project. Going with plain POSIX sh would make this available for all. I don't like hardcoded partitions, mlocate (do you really use mlocate?), multiple arch-chroot calls where you could just do a single big script, not handling os.system error codes (!), multiple pacman calls without even -Sy (!) (pacman can fail if upstream updates the repos), and few more things I don't like. Except for that, nice python abstraction and cool aim. I remember the old archlinux installation scripts few (or more) years ago, they were nice, however I think used commands themselves anyway. Good luck.
The way as below works for Ubuntu, I think it should work for Arch too.
First, you should have had a machine, which has installed the Arch. Then you add the user that you need with the two commands: useradd and passwd. After that, you could cat /etc/shadow | grep [username] to get the information of the password of the user added by you, it should be a string, let's say it is XXX.
Now, on your target system, after arch-chroot /mnt useradd -m -g users -G wheel -s /usr/bin/bash archuser, you add the string coming from cat /etc/shadow | grep [username] into the /etc/shadow of the target system. The command should be like arch-chroot /mnt sed -i "XXX" /etc/shadow.
One more thing, you must make sure that the version of the Arch which you get the information of the password and the version of the target system are the same.

Howto change Clonezilla default menu selection items

I am using clonezilla-live-2.6.1-11-amd64.iso
I would like to change the default section when booting off the live USB to perform full backups of the whole drive. for example:
on screen "Mount Clonezilla image directory" I would like to change the default from local_dev to use samba_server
on screen "Mount Samba server" I would like to change the default from 192.168.1.1 to 192.168.1.2
on screen "Mount Samba server" account change the default administrator to clonezilla
When I enter the items in
/syslinux/syslinux.cfg
.
ocs_repository="smb://clonezilla:password#192.168.1.2/zilla/
the menu's still ask me the default address of 192.18.1.1 and username administrator
so it appears I am not understanding the documentation. Does anyone have an example cfg?
I have delved into customizing "LiveISO's" and CloneZilla specifically so I will give a general idea of how I would attack this.
Looking at my notes this is all I had. To enable SSH Deamon I would unpack the ISO, edit the following and repack the iso using mksquashfs.
Eg:
Preparing to unpack ISO:
sudo apt-get install -y squashfs-tools
Copy iso to /tmp & rename live.iso
mkdir /tmp/mnt
sudo mount -o loop /tmp/live.iso /tmp/mnt
sudo find /tmp/mnt \( -name '*.squashfs' -o -name "*.SQFS" \) -exec unsquashfs -d /tmp/squashfs-root/ {} \;
sudo umount /tmp/mnt
sudo rm /tmp/mnt -R
cd /tmp/squashfs-root
This leaves you with:
/tmp/live.iso
/tmp/squashfs-root/FilesFromSquashedFS
Make Changes…..
sudo nano /tmp/squashfs-root/etc/ocs/ocs-live.conf
scroll to bottom & add:
ocs_daemon=\"ssh\"
Then Repack ISO:
cd /tmp
sudo mksquashfs /tmp/squashfs-root filesystem.squashfs
sudo rm /tmp/squashfs-root -R
This leaves you with:
/tmp/live.iso
/tmp/filesystem.squashfs
Now use an ISO editing Program to insert the filesystem.squashfs into the original ISO making sure to use the same name as the original ISO "squasedfs" used. Sometimes it's a different extension.
The above method is quite "General" but I found some LiveOS creators have scripts for booting the OS, making changes and then creating an ISO from the running OS.
For CloneZilla this is what I have found after a quick google.
https://clonezilla.org/advanced/customized-clonezilla-live.php
Simple Version of that Link:
Create Custom Script named custom-ocs ( A sample script file /usr/share/drbl/samples/custom-ocs)
Mount /home/partimag/
Copy script to /home/partimag/ and cd to /home/partimag/
Run the following to generate ISO
ocs-iso -g en_US.UTF-8 -k NONE -s -m ./custom-ocs
For other options, please run ocs-iso -h or ocs-live-dev -h to get more info.
Another Link (https://clonezilla.org/related-articles/012_Automated_USB_thumb_drive_using_Custom/Automated_USB_thumb_drive_using_Custom.html) shows this method which seems to indicate to me that if you place a script inside the ISO and then point to it via an edited syslinux.cfg (You could edit it using either of the above methods) you can auto-run it that way. The link says to boot USB and select first menu option, but I would want it to be fully automated where if you do nothing that option is selected regardless.
Here is the edit to syslinux.cfg that he uses:
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs noprompt noprompt ocs_live_run="/live/image/live/custom-ocs" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 ip=frommedia nolocales
Note: ocs_live_run="/live/image/live/custom-ocs" This to me means run this script after booting, but I haven't tested/messed with CloneZilla in a while.
Personal Opinion: I love Parted Magic but some people don't like that it has some weird licensing now and isn't really free, but old 2013 version can be found and/or buy it for like $10. It has CloneZilla built in and also an MKISO script for making an ISO out of the booted/edited/LiveOS, but again, I generally would unpack the ISO using squashfs and then repack and inject into ISO.
Here are my links to what I've done customizing "LiveISO's". My final project years ago was a "Parted Magic" LiveISO that booted, started a PWD protected VNC sessions + ssh and e-mailed me the DHCP IP address. (I had hit and miss results with the e-mail portion, but depending on your setup you could use static IP or check router for DHCP IP address)
https://www.freesoftwareservers.com/display/FREES/Customize+LiveISO%27s
You can indeed have your Samba share automatically pre-mounted by using ocs_repository= in your vmlinuz kernel boot arguments.
However, it needs to be in the right boot file.
According to the boot parameters documentation, the relevant file is one of:
/syslinux/isolinux.cfg when booting from CD on a MBR machine
/syslinux/syslinux.cfg when booting from USB flash drive on a MBR machine
/boot/grub/grub.cfg when booting from a uEFI machine
/tftpboot/pxelinux.cfg/default or similar on your PXE server, when booting from PXE on a MBR machine
/tftpboot/grub/grub.cfg or similar on your PXE server, when booting from a uEFI netboot machine
Depending on your Samba server, you might also need to specify the SMB version to be used. From the same documentation page:
To assign the image repository via URI (Uniform Resource Identifier),
use "ocs_repository". URI supported in Clonezilla live:
[dev|smb|smb1|smb1.0|smb2|smb2.0|smb2.1|smb3|smb3.0|smb3.11|smb3.1.1|ssh|nfs|nfs4|http|https|ram]:[//[user:password#]host[:port]][/]path

linux commands mkdir, rm -r and ln -s -T in processing phase of IZPack 5.0.0

I am using JBoss 7.1.1 application server with my java application in linux and have successfully been able to start JBoss during the processing phase of IZPack(processSpec.xml). I was getting "command not found" messages during the processing phase. I decided to get rid of all the comments and the messages went away. However, when I execute the uninstall, mkdir and ln -s -T appends a "?" at the end of the filename and link. Is this a bug? The rm -r successfuly removes the jboss script at /etc/init.d, but fails to remove the jboss-as.conf file at /etc/jboss-7.1.1.Final. I have jboss home at /usr/share. rm -r fails to remove /standalone and /modules. I get a popup during the uninstall stating administrative priveleges are required to remove /standalone and /modules.
All input is appreciated.
Glenn
rm(1) man page notes :
Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force option is not given, or the -i or
--interactive=always option is given, rm prompts the user for whether to remove the file. If the response is not affirma-tive, the file is skipped.
That appended ? after filename sounds like the prompt.
You're trying to remove files, that's readonly. rm -r is failing to remove things, probably because you don't own /standalone and /modules. Presumbably you needed "administrative privileges" to get things installed where they are in first place.

Is there a way to automate the return key after a linux script command?

I am using the line below in my script
add-apt-repository ppa:webupd8team/java
When it is run from the script I get a prompt to press [return] to confirm adding the source to the repositories
Can I automate that return?
Secondly, I am installing oracle-java7-installer and there is a license agreement that prompts for the user to:
1.. OK the License agreement
2.. select YES to Accept License Terms
Can I automate the OK and automate the keypad left & OK to Accept License Terms?
This script is for testing locally and I do want the script to pause for these user inputs each time.
I have seen this method of piping YES to a command:
yes | <command here>
I am hoping there is a similar method to automate these steps...
For add-apt-repository you can use the -y flag to skip the yes/no prompt.
The Oracle Java one is a little more complicated, but this will do what you want:
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
# Install required packages
sudo apt-get install oracle-java7-installer -y
The command echo will produce a new line!

Resources