Skip to content

Instantly share code, notes, and snippets.

View apunisal's full-sized avatar

Apurva Nisal apunisal

View GitHub Profile
@apunisal
apunisal / gist:38e81497bdb3f52cbb6e4ffad8032bde Provisioning and usage of unprivileged LXC containers via indirect login or script

Provisioning and usage of unprivileged LXC containers via indirect login or script

As I've discovered, managing LXC containers is fairly straightforward, but when building out a system for provisioning out user maintained instances of NodeBB, it was imperative that unprivileged LXC containers were used, so that in the event of shell breakout from NodeBB followed by privilege escalation of the saas user, the root user in the LXC container would only be an unprivileged user on the host machine.

During the course of development, I ran into numerous blockers when it came to managing LXC containers in unexpected circumstances. Namely:

  • Using LXC in a subshell is not directly supported. This usually happens under one of the following two circumstances:
    • After switching users via su or executing lxc-* commands as another user via sudo
    • Executing lxc-* commands via a program, application, or script. In my case, a Node.js application.
#include <windows.h>
#include <GL/glut.h>
#include<stdlib.h>
#include <Math.h>
#include<mmsystem.h>
#define PI 3.14159265f
// Global variables
GLfloat ballRadius = 0.3f; // Radius of the smiley
GLfloat ballX = -1.0f; // smiley's center (x, y) position
#include<iostream>
#include<ctime>
#include<fstream>
#include<string>
using namespace std;
ofstream f;
class Default //Contains all Average Values
{ protected:float D_Household=20.0;float D_Savings_Insurance=20.0;float D_Education=15.0;float D_Personal_Care_Medication=10.0;float D_Entertainment=2.0;float D_Holidays_hoteling=10.0;float D_Transportation=6.0;float D_Clothing=7.0;float D_Eves_Celebrations=5.0;float D_Other=5.0;};