Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.

icon.linkedin.jpgicon.twitter.jpg

  • Mounting a Samba Share From Linux Client to Linux Samba Server
    06/02/2017 10:49PM

    In order to be able to access a Samba share on a remote client as a mounted file system execute the following command, as root on the client:

    mount -t cifs -o user=<user-on-samba-share>,uid=<uid-on-local-macheine>,gid=<gid-on-local-machine>,rw,workgroup=<your-workgroup> //ip/share /mnt/mount-point-dir

    You will be prompted for the password for the user defined on the Samba server.

    If you are able to authenticate, and then get the following error:

    ls: reading directory .: Permission denied

    Check the SELinux context type of the directory on the samba share.  It should be samba_share_t

  • Solution for Executing Native Process from Java that Requires sudo
    12/22/2016 9:52AM

    If you are building a Java program that requires the ability to execute native commands on the machine which require sudo it requires some additional considerations other than just writing the Java code.

    The problem is that sudo, by default, requires a tty for executing sudo such that a password can entered.  Even if you configure sudoers to grant NOPASSWD access to a specific command you will still get the following error

    sudo: sorry, you must have a tty to run sudo

    In my case, I was writing a set of integration tests in Java that needed to be able to start and stop a service to run a test.

    I settled on adding an additional sudoers config file in /etc/sudoers.d.  This ended up be the cleanest and most encapsulated change that did not then require any special considerations in the Java code.

    The change simply involved adding a file with the following contents to /etc/sudoers.d which indicates that running sudo for the rchapin user does NOT require a tty and then grants access to the specific commands.

    Defaults:rchapin !requiretty
    rchapin ALL=(root) NOPASSWD: /bin/systemctl stop rabbitmq-server.service
    rchapin ALL=(root) NOPASSWD: /bin/systemctl start rabbitmq-server.service

  • Blacklisting Kernel Modules
    06/12/2016 12:14PM

    Following is a walkthrough on how to blacklist a kernel module.  The specific example is blacklisting the nouveau driver so that I can install the OEM Nvidia driver.

    1. First, blacklist the nouveau driver: Add a line to the textfile /etc/modprobe.d/nouveau-blacklist.conf that contains they keyword 'blacklist' and the name of the driver

    blacklist nouveau

    2. Rebuild the initramfs image file.  First, backup existing initramfs


    # mv initramfs-3.10.0-327.18.2.el7.x86_64.img initramfs-3.10.0-327.18.2.el7.x86_64.img_2016-06-09.bak

    Build new initramfs
    # dracut -v /boot/initramfs-$(uname -r).img $(uname -r)

    3. Reboot the system and confirm that the driver in question is not loaded.
    # lsmod | fgrep nouveau

  • Using netcat to Mock a RESTful Webservice that Returns JSON
    05/10/2016 10:26AM

    Let's say that you are working on a part of a project that needs to consume some JSON data from a forthcoming HTTP service.  That sub-system is being developed by one of your colleagues and is not yet ready for you to stand-up to develop against.

    You can use netcat to mock the webservice and return some static JSON data for which you can develop and test against with a simple one-liner.

    First, put together your JSON in a file, 'my.json' and then run the following command in a terminal:

    while true; do echo -e "HTTP/1.1 200 OK\r\n\r\n$(cat my.json)" | nc -l 9998; done

    An hitting http://localhost:9998 will return your test JSON data.

  • How to Use Credentials That Contain Special Characters with curl
    05/02/2016 12:00PM
    In order to execute curl commands to endpoints with passwords that contain special characters, the cleanest way that I have found to do so is to Base64 encode the authentication string for curl and then pass an Authorization request header along with the request.

    In this example the credentials are uid 'rchapin' and passwd 'abc123!@#'.  Normally we would pass this to curl as follows:

    $ curl -u rchapin:abc123!@# -X GET https://some-endpoint:443

    However, this will not work and the password will need to be sent in some other fashion other than ASCII.

    Following are the steps to pass the credentials as Base64:

    1. Using your favorite Base64 encoder, generate and ASCII string of the entire 'username:password' strin
    g that you would normally pass with the -u option for curl

    rchapin:abc123!@# converted = cmNoYXBpbjphYmMxMjMhQCM=

    2. Now modify the curl command as follows:

    $ curl -H "Authorization: Basic cmNoYXBpbjphYmMxMjMhQCM=" -X GET https://some-endpoint:443
  • 1 2 3 4 5 6 7 8 9 10 11 12 13 >>
Advanced Search

Categories

Archives