Commit Graph

114 Commits

Author SHA1 Message Date
Ken Moore
fd5bc59d00 Fix up a bit more of the event system within the websocket class after some testing with the client. 2016-01-20 09:54:00 -05:00
Ken Moore
89865b5a2d Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-19 16:18:56 -05:00
Ken Moore
d99871c117 Add in support for Life Preserver events. 2016-01-19 16:17:59 -05:00
Kris Moore
d4f2e302bc OSX Doesn't support TLS 1.1 or 1.2, so we fallback to 1.0 2016-01-19 15:05:18 -05:00
Ken Moore
7ebc12aaf7 Add handling/debug output for connection errors in the websocket server. 2016-01-19 14:49:46 -05:00
Ken Moore
27ebde481d Make sure the "auth" requests are always run in order - do asyncronous event handling after auth is already setup. 2016-01-19 12:36:19 -05:00
Ken Moore
2260d06ee2 Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-19 12:33:32 -05:00
Ken Moore
ee7a5a9d43 Enable QtConcurrent for the message reply generation systems. 2016-01-19 12:33:00 -05:00
Kris Moore
01cad39043 Add new API call for "update" class to check system for updates.
Possible response arrays include

"security":{ "name":"FreeBSD System Update" }
"majorupgrade":{ "name":"Update to 10.3", "tag":"releng10.3", "version":"10.3-RELEASE" }
"patch":{ "name":"StandAlone Update", "tag":"mypatch", "details":"Updates PKG to FOO", "date":"20160120", "size":"5MB" }
"pkgupdate":{ "name":"System Package Updates" }

REST Request:
-------------------------------
PUT /sysadm/update
{
   "action" : "checkupdates"
}

REST Response:
-------------------------------
{
    "args": {
        "checkupdates": {
            "status": "noupdates"
        }
    }
}

  bSocket Request:
-------------------------------
{
   "name" : "update",
   "args" : {
      "action" : "checkupdates"
   },
   "namespace" : "sysadm",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "checkupdates": {
      "status": "noupdates"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-19 12:27:03 -05:00
Ken Moore
0077d68208 Commit some debugging work on the sysadm server. 2016-01-18 16:53:12 -05:00
Kris Moore
766305dcdf Add new "update" API class with the first "checkupdates" action for
testing. We will add an API call for doc'ing once we troubleshoot
some issues
2016-01-18 15:07:57 -05:00
Ken Moore
ae054b759a Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-18 12:38:14 -05:00
Ken Moore
f30b6cf947 Finish up the overhaul of the Events subsystem and start adding in the Life Preserver event handling/systems. 2016-01-18 12:37:40 -05:00
Kris Moore
de4a7bd3c6 Make pid files 744, and update sysadm-global.h with some cleanup 2016-01-18 12:34:50 -05:00
Ken Moore
a2c054e48e Merge branch 'master' of github.com:pcbsd/sysadm 2016-01-15 15:36:58 -05:00
Ken Moore
82b549ead3 Split off the Events subsystem from the server class and set it up for easy expansion later. 2016-01-15 15:36:04 -05:00
Ken Moore
5a1882dda5 Merge pull request #6 from ldemouy/master
Switch LoadUser and LoadGroup over to using pw usershow/groupshow -a
2016-01-15 14:02:37 -05:00
Luke De Mouy
ff2dcc83b7 Switch LoadUser and LoadGroup over to using pw usershow/groupshow -a 2016-01-15 11:52:56 -07:00
Kris Moore
84cb7bb19d Add new API call to run replication tasks manually
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "host" : "10.0.10.100",
   "dataset" : "mypool",
   "action" : "runreplication"
}

REST Response:
-------------------------------
{
    "args": {
        "runreplication": {
            "dataset": "mypool",
            "host": "10.0.10.100"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "lifepreserver",
   "args" : {
      "host" : "10.0.10.100",
      "dataset" : "mypool",
      "action" : "runreplication"
   },
   "namespace" : "sysadm"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "runreplication": {
      "dataset": "mypool",
      "host": "10.0.10.100"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-15 12:11:01 -05:00
Kris Moore
f31d53587f Add new API call to remove a replication task / target
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "dataset" : "tank",
   "host" : "192.168.0.10",
   "action" : "removereplication"
}

REST Response:
-------------------------------
{
    "args": {
        "removereplication": {
            "dataset": "tank",
            "host": "192.168.0.10"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "action" : "removereplication",
      "dataset" : "tank",
      "host" : "192.168.0.10"
   },
   "name" : "lifepreserver",
   "namespace" : "sysadm"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "removereplication": {
      "dataset": "tank",
      "host": "192.168.0.10"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-15 12:01:28 -05:00
Kris Moore
97e8af86cf New API call for lifepreserver. This one lists the replication
targets on a system

While here, update api-test.sh to save response to /tmp/api-response, so we dont
need to always cut-n-paste

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "listreplication"
}

REST Response:
-------------------------------
{
    "args": {
        "listreplication": {
            "tank1->192.168.0.9": {
                "dataset": "tank1",
                "frequency": "22",
                "host": "192.168.0.9",
                "port": "22",
                "rdset": "tank/backups",
                "user": "backups"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "args" : {
      "action" : "listreplication"
   },
   "id" : "fooid",
   "name" : "lifepreserver"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "listreplication": {
      "tank1->192.168.0.9": {
        "dataset": "tank1",
        "frequency": "22",
        "host": "192.168.0.9",
        "port": "22",
        "rdset": "tank/backups",
        "user": "backups"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-15 10:40:03 -05:00
Ken Moore
68b01bca4f Merge pull request #5 from ldemouy/master
Add uid and gid back in and add in personacrypt
2016-01-15 09:05:14 -05:00
Luke De Mouy
3347669b6e Copy the PersonaCrypt Functions from the maindlgcode file and wire it up
to user creation and password changing
2016-01-14 15:01:04 -07:00
Kris Moore
48d7108529 Add a new API call to (re)init the replication on the remote
side via life-preserver

dataset = The local dataset/pool you are replicating
host = The target for replication, either IP or hostname

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "dataset" : "tank1",
   "host" : "192.168.0.9",
   "action" : "initreplication"
}

REST Response:
-------------------------------
{
    "args": {
        "initreplication": {
            "dataset": "tank1",
            "host": "192.168.0.9"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "host" : "192.168.0.9",
      "dataset" : "tank1",
      "action" : "initreplication"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "initreplication": {
      "dataset": "tank1",
      "host": "192.168.0.9"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-14 15:17:25 -05:00
Luke De Mouy
553b14185b add ability to set the uid and gid when creating a user back in 2016-01-14 11:15:14 -07:00
Ken Moore
4dcdaf2cb9 Merge pull request #4 from ldemouy/master
Create a UserManager for sysadm
2016-01-14 10:14:09 -05:00
Luke De Mouy
66c878697c Add Default Constructors to users and groups, and change Users to
Members in the Group class.
2016-01-13 20:38:42 -07:00
Luke De Mouy
b099e477ee various fixes to make things work and a few style changes, namely
General::ExecuteCommand cannot execute a command with a space in it so
it has to be added as an arg, and switched from .append to <<
2016-01-13 19:49:05 -07:00
Luke De Mouy
dbe7a84c3e Simply password changing code so that it doesn't repeat itself between
being and not being in a chroot
2016-01-13 18:04:14 -07:00
Luke De Mouy
b2368aadd4 Document all of the member functions in the header 2016-01-13 17:52:09 -07:00
Luke De Mouy
3d16bc3456 simplify the process for creating a new user and switch all system calls
over to using General::RunCommand();
2016-01-13 17:35:22 -07:00
Luke De Mouy
942d158db3 Document the functionality to create a new user and transfer it over to
using sysadm-general, this commit is done in preparation for simplifying
things from the following:

create zfs dataset -> create group associated with user -> manually
create the home directory -> Create the user, passing in the flags that
would have otherwise created the home directory normally, and sets the
groupID to that of the group we created before (which it should
automatically do if we don't specify a group) -> set the user password -
> enable flash -> chown the home folder over to the user

to:
create zfs dataset -> create the user using appropriate flags -> set user
password -> enable flash
2016-01-13 16:05:31 -07:00
Ken Moore
ec7f25d804 Add a new API call: namespace=rpc, name=query
This will probe all the known subsystems and return which ones are currently available and what level of access the user has (read/write).

REST Request:
-------------------------------
PUT /rpc/query
{
   "junk" : "junk"
}

REST Response:
-------------------------------
{
    "args": {
        "rpc/dispatcher": "read/write",
        "rpc/syscache": "read",
        "sysadm/lifepreserver": "read/write",
        "sysadm/network": "read/write"
    }
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "name" : "query",
   "namespace" : "rpc",
   "args" : {
      "junk" : "junk"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "rpc/dispatcher": "read/write",
    "rpc/syscache": "read",
    "sysadm/lifepreserver": "read/write",
    "sysadm/network": "read/write"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "rpc"
}
2016-01-13 14:21:45 -05:00
Ken Moore
d93b0a5ba7 Add a new auth subsystem to teh backend of the server.
Now the user's who login are divided up into "Full Access" users or not. This allows for additional restrictions in the backend subsystems to restrict certain types of operations to only the "full access" (root-permissioned) users.
The users are divided up like this:
1) The user must be in either the "wheel" or "operator" groups to get any access whatsoever (restricting automated services from connecting).
2) If the user is in the "wheel" group, they get full access to the server's capabilities
3) If the user is in the "operator" group instead, then they only get limited access to the server's capabilities.

While here, also allow password-less logins to the server if the client is connecting to a server on the same system (local access). User restrictions still apply.
2016-01-13 13:12:10 -05:00
Luke De Mouy
30c71db6ae Create the UserManager class, and pull in the functionality from the old
usermanager backend. Brings in the following functionality:
*Create/Delete User
*Create/Delete Group
*Add/Remove User from Group
*Change a Users Password/Shell/Full Name
*Get the list of Users, Groups, and Shells
2016-01-12 19:39:41 -07:00
Kris Moore
5bb6fb7d33 Add new API call for creating a replication task in Life-Preserver
host = <Remote hostname/ip>
port = <SSH port>
password = <Your SSH password>
dataset = <Local Dataset to replicate>
remotedataset = <Target location for remote dataset>
frequency = <time> XX/sync/hour/30min/10min/manual
            XX= Time to perform replication (in 24 hour notation)
          sync= Do replication with snaps (Not recommended for frequent snaps)
          hour= Replicate hourly
         30min= Replicate every 30 minutes
         10min= Replicate every 10 minutes
        manual= Only replicate when requested by user

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "addreplication",
   "password" : "mypass",
   "dataset" : "tank1",
   "remotedataset" : "tank/backups",
   "user" : "backupuser",
   "frequency" : "22",
   "port" : "22",
   "host" : "192.168.0.10"
}

REST Response:
-------------------------------
{
    "args": {
        "addreplication": {
            "frequency": "22",
            "host": "192.168.0.10",
            "ldataset": "tank1",
            "port": "22",
            "rdataset": "tank/backups",
            "user": "backupuser"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "name" : "lifepreserver",
   "args" : {
      "action" : "addreplication",
      "user" : "backupuser",
      "dataset" : "tank1",
      "frequency" : "22",
      "port" : "22",
      "password" : "mypass",
      "host" : "192.168.0.10",
      "remotedataset" : "tank/backups"
   },
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "addreplication": {
      "frequency": "22",
      "host": "192.168.0.10",
      "ldataset": "tank1",
      "port": "22",
      "rdataset": "tank/backups",
      "user": "backupuser"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 16:53:46 -05:00
Kris Moore
4158f4589c Add new API call to save system-wide settings for life-preserver
duwarn = XX (Percentage, 1-99)
email = Email address to send notifications to
emailopts = ALL/WARN/ERROR (All mail, warnings + errors, or errors only)
recursive = true/false (Do recursive operations on all ZFS snap)

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "emailopts" : "ALL",
   "duwarn" : "70",
   "recursive" : "true",
   "action" : "savesettings",
   "email" : "kris@example.org"
}

REST Response:
-------------------------------
{
    "args": {
        "savesettings": {
            "duwarn": "70",
            "email": "kris@example.org",
            "emailopts": "ALL",
            "recursive": "true"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "emailopts" : "ALL",
      "action" : "savesettings",
      "duwarn" : "70",
      "recursive" : "true",
      "email" : "kris@example.org"
   },
   "id" : "fooid",
   "namespace" : "sysadm",
   "name" : "lifepreserver"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "savesettings": {
      "duwarn": "70",
      "email": "kris@example.org",
      "emailopts": "ALL",
      "recursive": "true"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 14:39:10 -05:00
Kris Moore
399bfb3814 Add new API call to remove ZFS snapshots from a dataset / pool
REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "dataset" : "tank1/usr/jails",
   "snap" : "auto-2016-01-09-18-00-00",
   "action" : "removesnap"
}

REST Response:
-------------------------------
{
    "args": {
        "removesnap": {
            "dataset": "tank1/usr/jails",
            "snap": "auto-2016-01-09-18-00-00"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "snap" : "auto-2016-01-09-18-00-00",
      "action" : "removesnap",
      "dataset" : "tank1/usr/jails"
   },
   "name" : "lifepreserver",
   "namespace" : "sysadm",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
     "removesnap": {
        "dataset": "tank1/usr/jails",
        "snap": "auto-2016-01-09-18-00-00"
     }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 13:51:24 -05:00
Kris Moore
c506bcccb5 Add new API call for reverting a dataset back to a
specific snapshot

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "snap" : "auto-2016-01-09-18-00-00",
   "dataset" : "tank1/usr/jails",
   "action" : "revertsnap"
}

REST Response:
-------------------------------
{
    "args": {
        "revertsnap": {
            "dataset": "tank1/usr/jails",
            "snap": "auto-2016-01-09-18-00-00"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "dataset" : "tank1/usr/jails",
      "action" : "revertsnap",
      "snap" : "auto-2016-01-09-18-00-00"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "revertsnap": {
      "dataset": "tank1/usr/jails",
      "snap": "auto-2016-01-09-18-00-00"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 13:36:42 -05:00
Kris Moore
f659ce2fb1 Merge pull request #3 from ldemouy/master
Move system() calls over to their equivalents from sysadm-general.
2016-01-12 13:14:20 -05:00
Kris Moore
8f4deefda2 This is a change to the "listcron" API call, specifically it
adds the "scrub":"<value>" data, so if a scrub is scheduled for
a pool, it will be listed alongside the snap schedule, or on
its own if no snapshots are scheduled

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "listcron"
}

REST Response:
-------------------------------
{
    "args": {
        "listcron": {
            "tank1": {
                "keep": "3",
                "schedule": "daily@18",
                "scrub": "daily@22"
            }
        }
    }
}

WebSocket Request:
-------------------------------
{
   "name" : "lifepreserver",
   "id" : "fooid",
   "namespace" : "sysadm",
   "args" : {
      "action" : "listcron"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "listcron": {
      "tank1": {
        "keep": "3",
        "schedule": "daily@18",
        "scrub": "daily@22"
      }
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 13:03:51 -05:00
Luke De Mouy
de6e1b41de Move system() calls over to their equivalents from sysadm-general.
Note: It would probably be a good idea for sysadm-general to have an API
for changing rc.conf
2016-01-12 10:48:00 -07:00
Kris Moore
cbf3ce8b8b Add new API call to schedule a cron scrub
Frequency Options: none, daily@XX, weekly@YY@XX, monthly@ZZ@XX
XX = Hour to execute, YY = Day of week to execute, ZZ = Day of month

REST Request:
-------------------------------
PUT /sysadm/lifepreserver
{
   "action" : "cronscrub",
   "pool" : "tank",
   "frequency" : "daily@22"
}

REST Response:
-------------------------------
{
    "args": {
        "cronscrub": {
            "frequency": "daily@22",
            "pool": "tank"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "args" : {
      "action" : "cronscrub",
      "pool" : "tank",
      "frequency" : "daily@22"
   },
   "namespace" : "sysadm",
   "name" : "lifepreserver",
   "id" : "fooid"
}

WebSocket Response:
-------------------------------
{
  "args": {
    "cronscrub": {
      "frequency": "daily@22",
      "pool": "tank"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
2016-01-12 12:12:19 -05:00
Luke De Mouy
58db613ab7 Refactor to use Range Based For Loops since C++11 is enabled, also add
in LoadOpenPorts to the function to reset to the default config, so that
we have the correct set of open ports.
2016-01-12 02:58:35 -07:00
Luke De Mouy
43a4274565 Add in the ability to close or open multiple ports at once, by passing
in a QVector<PortInfo> to the OpenPort and ClosePort functions,
2016-01-12 02:37:07 -07:00
Luke De Mouy
aec5ce9aeb Move the #include<tuple> to where it should be in the header file as
opposed to the cpp
2016-01-12 02:26:06 -07:00
Luke De Mouy
4645d2fa20 rename PortType to Type, and simply the argument names from functions
from portType and portNumber to type and number respectively
2016-01-11 19:38:42 -07:00
Luke De Mouy
20ee1eaf62 Switch openports from being a nonintuitive string to using our PortInfo
struct and add comments to the /etc/ipfw.openports file when we write to
it.

Enable C++11 in the library.pro file as it's required for std::sort and
std::tie, since qSort is deprecated as of Qt 5.3
2016-01-11 19:28:02 -07:00
Luke De Mouy
17d2c131b5 Add in the option to restore the default configuration 2016-01-11 15:02:07 -07:00
Luke De Mouy
21f5cf6265 Add license header on firewall cpp file 2016-01-11 14:29:42 -07:00